| juin_2013 | dec_2013 | juin_2014 | dec_2014 | |
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 707610 | 547183 | 566386 | 397872 |
| AC3: Créances sur la clientèle | 5426908 | 5484548 | 5785084 | 6116034 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 890448 | 986109 | 1174729 | 1279001 |
| AC6: Valeurs immobilisées | 109751 | 111765 | 114709 | 113024 |
| AC7: Autres actifs | 63897 | 96026 | 92100 | 88946 |
| Total actifs | 7198614 | 7225631 | 7733008 | 7994877 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 846155 | 656637 | 649379 | 669723 |
| PA3: Dépôts et avoirs de la clientèle | 4771687 | 4964477 | 5392386 | 5534662 |
| PA4: Emprunts et Ressources spéciales | 866480 | 846029 | 908666 | 895487 |
| PA5: Autres passifs | 119823 | 190029 | 178860 | 259758 |
| Total passifs | 6604145 | 6657172 | 7129291 | 7359630 |
| CP1: Capital | 122220 | 122220 | 122220 | 122220 |
| CP2: Réserves | 422421 | 346012 | 423377 | 423431 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 49407 | 99806 | 57700 | 89176 |
| Total capitaux propres | 594469 | 568459 | 603717 | 635247 |
| Total capitaux propres et passifs | 7198614 | 7225631 | 7733008 | 7994877 |
| juin_2015 | dec_2015 | juin_2016 | dec_2016 | |
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 319974 | 301654 | 236519 | 277550 |
| AC3: Créances sur la clientèle | 6100492 | 5971463 | 5951069 | 5893685 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 1369500 | 1476770 | 1599123 | 1792430 |
| AC6: Valeurs immobilisées | 117890 | 117566 | 122248 | 120854 |
| AC7: Autres actifs | 82798 | 72601 | 155557 | 158398 |
| Total actifs | 7990654 | 7940054 | 8064516 | 8242917 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1107235 | 1009424 | 1038815 | 1287062 |
| PA3: Dépôts et avoirs de la clientèle | 5089757 | 5142391 | 5224553 | 5116938 |
| PA4: Emprunts et Ressources spéciales | 928129 | 911881 | 885063 | 914432 |
| PA5: Autres passifs | 195751 | 205186 | 235983 | 190154 |
| Total passifs | 7320872 | 7268882 | 7384414 | 7508586 |
| CP1: Capital | 122220 | 122220 | 122220 | 127313 |
| CP2: Réserves | 488010 | 488066 | 521710 | 516585 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 59128 | 60462 | 35750 | 90011 |
| Total capitaux propres | 669782 | 671172 | 680102 | 734331 |
| Total capitaux propres et passifs | 7990654 | 7940054 | 8064516 | 8242917 |
| juin_2017 | dec_2017 | juin_2018 | dec_2018 | |
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 284855 | 367277 | 345694 | 585581 |
| AC3: Créances sur la clientèle | 6002207 | 6073730 | 6127435 | 5929248 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 1927681 | 1892208 | 2035218 | 1897993 |
| AC6: Valeurs immobilisées | 121087 | 163219 | 164094 | 166778 |
| AC7: Autres actifs | 150841 | 159764 | 161673 | 233528 |
| Total actifs | 8486671 | 8656198 | 8834114 | 8813128 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1452748 | 1559931 | 1479531 | 1307122 |
| PA3: Dépôts et avoirs de la clientèle | 5132643 | 5137206 | 5372311 | 5516889 |
| PA4: Emprunts et Ressources spéciales | 982621 | 968065 | 922959 | 876255 |
| PA5: Autres passifs | 163567 | 172039 | 209673 | 207581 |
| Total passifs | 7731579 | 7837241 | 7984474 | 7907847 |
| CP1: Capital | 132406 | 132405 | 132405 | 132405 |
| CP2: Réserves | 572184 | 572213 | 652693 | 652478 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 50079 | 113916 | 64140 | 119996 |
| Total capitaux propres | 755092 | 818957 | 849640 | 905281 |
| Total capitaux propres et passifs | 8486671 | 8656198 | 8834114 | 8813128 |
| juin_2019 | dec_2019 | juin_2020 | dec_2020 | |
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 776744 | 1029846 | 672299 | 657970 |
| AC3: Créances sur la clientèle | 5764161 | 5727900 | 5849074 | 6003059 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 1816480 | 1794738 | 1913060 | 2114255 |
| AC6: Valeurs immobilisées | 176093 | 188436 | 193408 | 208163 |
| AC7: Autres actifs | 206109 | 210993 | 177425 | 194124 |
| Total actifs | 8739587 | 8951913 | 8805266 | 9177571 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1336418 | 1299523 | 978034 | 1023860 |
| PA3: Dépôts et avoirs de la clientèle | 5492292 | 5559635 | 5703385 | 5861002 |
| PA4: Emprunts et Ressources spéciales | 815005 | 875676 | 830431 | 968332 |
| PA5: Autres passifs | 158205 | 202531 | 239962 | 210426 |
| Total passifs | 7801920 | 7937365 | 7751812 | 8063620 |
| CP1: Capital | 132405 | 132405 | 132405 | 132405 |
| CP2: Réserves | 736510 | 736529 | 844595 | 844373 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 105394 | 182256 | 38945 | 99664 |
| Total capitaux propres | 937667 | 1014548 | 1053454 | 1113951 |
| Total capitaux propres et passifs | 8739587 | 8951913 | 8805266 | 9177571 |
| juin_2021 | dec_2021 | juin_2022 | dec_2022 | |
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 967263 | 529335 | 809511 | 587954 |
| AC3: Créances sur la clientèle | 6121170 | 6245664 | 6541211 | 6889784 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 2148062 | 2270398 | 2243374 | 2368299 |
| AC6: Valeurs immobilisées | 245946 | 270250 | 296811 | 397473 |
| AC7: Autres actifs | 177987 | 227763 | 210291 | 163260 |
| Total actifs | 9660428 | 9543410 | 10101198 | 10406770 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1155600 | 854460 | 1194680 | 1057694 |
| PA3: Dépôts et avoirs de la clientèle | 6132793 | 6343825 | 6619725 | 6990819 |
| PA4: Emprunts et Ressources spéciales | 957216 | 926283 | 840359 | 825551 |
| PA5: Autres passifs | 288729 | 232599 | 214701 | 230533 |
| Total passifs | 8534338 | 8357167 | 8869465 | 9104597 |
| CP1: Capital | 132405 | 132405 | 132405 | 132405 |
| CP2: Réserves | 924022 | 923755 | 1014792 | 1014465 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 69236 | 129656 | 84112 | 154879 |
| Total capitaux propres | 1126090 | 1186243 | 1231733 | 1302173 |
| Total capitaux propres et passifs | 9660428 | 9543410 | 10101198 | 10406770 |
#####visualisation
ts.ac3<-ts(rev(b$ac3),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.ac3)
# plot(decompose(ts.ac3))
# stl(ts.ac12,s.window="periodic")
La variable AC3 est une variable cumulative: elle désigne un total cumulatif ou une accumulation de la valeur des créances sur la clientèle au fil du temps et ne présente donc pas un comportement saisonnier.
Les fonction de décompostion dans R (decompose() et STL()) arrrivent toujours à trouver une composante saisonnière pour n’importe quel type de séries temporelles contenant au moins deux périodes complètes de données via leurs algorithmes implémentés.
Généralement, on peut conclure quant au caractère saisonnier d’une série temporelle en se basant sur sa représentation graphique et ses corrélogrammes (ACF et PACF plots).
Le package seastests dans R contient plusieurs tests de saisonnalité des séries temporelles:
La fonction isSeasonal(): retourne TRUE si la série présente un comportement saisonnier, FALSE sinon.
Le test combiné de saisonnalité de Ollech et Webel’s.
Le test de saisonnalité de Friedman.
isSeasonal(ts.ac3)
## [1] FALSE
combined_test(ts.ac3, 2)
## Test used: WO
##
## Test statistic: 0
## P-value: 1 0.86 0.199
fried(ts.ac3, 2)
## Test used: Friedman rank
##
## Test statistic: 0.11
## P-value: 0.739
‘By default, the WO-test combines the results of the QS-test and the kw-test, both calculated on the residuals of an automatic non-seasonal ARIMA model. If the p-value of the QS-test is below 0.01 or the p-value of the kw-test is below 0.002, the WO-test will classify the corresponding time series as seasonal.’ Source: “https://cran.r-project.org/web/packages/seastests/seastests.pdf”.
Les trois tests affirment l’absence de saisonnalité pour la variable AC3 (p-values> 0.01 et 0.002).
fit3.ets<-ets(ts.ac3)
# autoplot(fit3.ets)
#summary(fit3.ets)
# checkresiduals(fit3.ets)
autoplot(ts.ac3, color = "white", lwd = 2) +
autolayer(fit3.ets$fitted, color = "blue")
forecast.ets(fit3.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 7238363 6967707 7509020 6824429 7652298
## 2023.50 7586948 6975645 8198252 6652040 8521857
## 2024.00 7935533 6900689 8970377 6352875 9518191
## 2024.50 8284118 6750625 9817611 5938843 10629393
## 2025.00 8632703 6529970 10735435 5416851 11848554
## 2025.50 8981287 6241316 11721259 4790863 13171712
## 2026.00 9329872 5886009 12773735 4062939 14596806
## 2026.50 9678457 5464513 13892401 3233786 16123128
## 2027.00 10027042 4976607 15077476 2303069 17751014
## 2027.50 10375627 4421510 16329744 1269590 19481663
#flat prediction
fit3.holt<-holt(ts.ac3)
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
# summary(fit12.holt)
# checkresiduals(fit12.holt)
forecast(fit3.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 7238363 7014125 7462602 6895421 7581306
## 2023.50 7586948 7085577 8088320 6820167 8353730
## 2024.00 7935533 7096589 8774477 6652479 9218587
## 2024.50 8284118 7056034 9512202 6405926 10162310
## 2025.00 8632703 6969872 10295533 6089623 11175783
## 2025.50 8981287 6842404 11120171 5710148 12252427
## 2026.00 9329872 6676915 11982829 5272525 13387220
## 2026.50 9678457 6476016 12880898 4780746 14576168
## 2027.00 10027042 6241845 13812239 4238083 15816001
## 2027.50 10375627 5976197 14775056 3647280 17103973
autoplot(ts.ac3, color = "white", lwd = 2) +
autolayer(fit3.holt$fitted, color = "blue")
fit3.hw<-hw(ts.ac3)
# autoplot(fit3.hw)
# summary(fit3.hw)
# checkresiduals(fit3.hw)
autoplot(ts.ac3, color = "white", lwd = 2) +
autolayer(fit3.hw$fitted, color = "blue")
####ARIMA
acf(ts.ac3)
pacf(ts.ac3)
fit3.arima<-auto.arima(ts.ac3)
# autoplot(fit3.arima)
# summary(fit3.arima)
# checkresiduals(fit3.arima)
autoplot(ts.ac3, color = "white", lwd = 2) +
autolayer(fit3.arima$fitted, color = "blue")
forecast(fit3.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 7011823 6835579 7188066 6742282 7281364
## 2023.50 7011823 6671001 7352645 6490580 7533065
## 2024.00 7011823 6563205 7460440 6325721 7697924
## 2024.50 7011823 6476701 7546945 6193424 7830221
## 2025.00 7011823 6402353 7621293 6079719 7943926
## 2025.50 7011823 6336137 7687509 5978450 8045195
## 2026.00 7011823 6275854 7747791 5886256 8137389
## 2026.50 7011823 6220149 7803496 5801062 8222583
## 2027.00 7011823 6168113 7855532 5721481 8302165
## 2027.50 7011823 6119106 7904539 5646530 8377115
fit3.TBATS<-tbats(ts.ac3)
autoplot(fit3.TBATS)
summary(fit3.TBATS)
## Length Class Mode
## lambda 0 -none- NULL
## alpha 1 -none- numeric
## beta 1 -none- numeric
## damping.parameter 1 -none- numeric
## gamma.values 0 -none- NULL
## ar.coefficients 0 -none- NULL
## ma.coefficients 0 -none- NULL
## likelihood 1 -none- numeric
## optim.return.code 1 -none- numeric
## variance 1 -none- numeric
## AIC 1 -none- numeric
## parameters 2 -none- list
## seed.states 2 -none- numeric
## fitted.values 20 ts numeric
## errors 20 ts numeric
## x 40 -none- numeric
## seasonal.periods 0 -none- NULL
## y 20 ts numeric
## call 2 -none- call
## series 1 -none- character
## method 1 -none- character
checkresiduals(fit3.TBATS)
##
## Ljung-Box test
##
## data: Residuals from TBATS
## Q* = 3, df = 4, p-value = 0.6
##
## Model df: 0. Total lags used: 4
autoplot(ts.ac3, color = "white", lwd = 2) +
autolayer(fit3.TBATS$fitted, color = "blue")
#### Model comparison
autoplot(ts.ac3, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fit3.ets$fitted, color = "red")+autolayer (fit3.arima$fitted, color = "blue")+autolayer(fit3.holt$fitted, color = "red")
grid.arrange(autoplot(forecast(fit3.ets,h=5)), autoplot(forecast(fit3.arima,h=5)),autoplot(forecast(fit3.holt,h=5)))
f3.ets <- function (y,h) forecast(fit3.ets,h=h)
f3.arima <- function (y,h) forecast(fit3.arima,h=h)
f3.holt<- function (y,h) forecast(fit3.holt,h=h)
hmax<-5
e3.ets<-na.omit(tsCV(ts.ac3,f3.ets,h=hmax))[,hmax]
e3.arima<-na.omit(tsCV(ts.ac3,f3.arima,h=hmax))[,hmax]
e3.holt<-na.omit(tsCV(ts.ac3,f3.holt,h=hmax))[,hmax]
summary(data.frame(e3.ets^2,e3.arima^2,e3.holt^2))
## e3.ets.2 e3.arima.2 e3.holt.2
## Min. :3037765276560 Min. : 14893439492 Min. :3037765311980
## 1st Qu.:6292080917890 1st Qu.: 787701883014 1st Qu.:6292080968870
## Median :6919507147390 Median :1019323821930 Median :6919507200860
## Mean :6638421852340 Mean : 966837706696 Mean :6638421904370
## 3rd Qu.:7405442141040 3rd Qu.:1211099905290 3rd Qu.:7405442196340
## Max. :8437878195520 Max. :1648457449010 Max. :8437878254550
a<- read.xlsx("C:/Users/wassi/OneDrive/Bureau/Bilanc.xlsx")
t3<-ts(rev(a$ac3),start=2015,frequency=1)
r<-holt(t3)
grid.arrange(autoplot(t3, color = "white", lwd = 2) +
autolayer(r$fitted, color = "blue"),autoplot(ts.ac3, color = "white", lwd = 2) +
autolayer(fit3.ets$fitted, color = "blue"))
v3<-fit3.ets$fitted
e3<-abs(v3-ts.ac3)/ts.ac3
summary(e3)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0010 0.0058 0.0186 0.0205 0.0309 0.0568
mean(e3)
## [1] 0.0205
comp<-data.frame()
comp<-cbind(ts.ac3,v3)
cn8 <- c("AC3","AC3_fitted")
rn8 <- c("juin_2013","dec_2013","juin_2014","dec_2014","juin_2015","dec_2015","juin_2016","dec_2016","juin_2017","dec_2017","juin_2018","dec_2018","juin_2019","dec_2019","juin_2020","dec_2020","juin_2021","dec_2021","juin_2022","dec_2022")
rownames(comp) <- rn8
knitr::kable(comp, col.names = cn8, row.names = TRUE)
| AC3 | AC3_fitted | |
|---|---|---|
| juin_2013 | 5426908 | 5649758 |
| dec_2013 | 5484548 | 5260854 |
| juin_2014 | 5785084 | 5542121 |
| dec_2014 | 6116034 | 6085594 |
| juin_2015 | 6100492 | 6447002 |
| dec_2015 | 5971463 | 6085022 |
| juin_2016 | 5951069 | 5842422 |
| dec_2016 | 5893685 | 5930642 |
| juin_2017 | 6002207 | 5836319 |
| dec_2017 | 6073730 | 6110692 |
| juin_2018 | 6127435 | 6145277 |
| dec_2018 | 5929248 | 6181140 |
| juin_2019 | 5764161 | 5731110 |
| dec_2019 | 5727900 | 5599042 |
| juin_2020 | 5849074 | 5691616 |
| dec_2020 | 6003059 | 5970229 |
| juin_2021 | 6121170 | 6157053 |
| dec_2021 | 6245664 | 6239291 |
| juin_2022 | 6541211 | 6370153 |
| dec_2022 | 6889784 | 6836724 |
#####visualisation
ts.pa3<-ts(rev(b$pa3),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.pa3)
# plot(decompose(ts.pa3))
fitp3.ets<-ets(ts.pa3)
# autoplot(fit3.ets)
#summary(fit3.ets)
# checkresiduals(fit3.ets)
autoplot(ts.pa3, color = "white", lwd = 2) +
autolayer(fitp3.ets$fitted, color = "blue")
forecast.ets(fitp3.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 6990782 6594475 7387088 6384683 7596880
## 2023.50 6990782 6430074 7551490 6133253 7848311
## 2024.00 6990782 6303733 7677831 5940031 8041532
## 2024.50 6990782 6197065 7784499 5776896 8204668
## 2025.00 6990782 6102949 7878615 5632959 8348605
## 2025.50 6990782 6017737 7963827 5502638 8478926
## 2026.00 6990782 5939261 8042303 5382619 8598944
## 2026.50 6990782 5866110 8115454 5270745 8710819
## 2027.00 6990782 5797304 8184259 5165515 8816048
## 2027.50 6990782 5732131 8249433 5065841 8915723
#flat prediction
fitp3.holt<-holt(ts.pa3)
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
# summary(fit12.holt)
# checkresiduals(fit12.holt)
forecast(fitp3.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 7057917 6763337 7352498 6607395 7508439
## 2023.50 7125046 6708446 7541645 6487912 7762180
## 2024.00 7192175 6681929 7702420 6411822 7972527
## 2024.50 7259303 6670098 7848508 6358192 8160414
## 2025.00 7326432 6667651 7985213 6318914 8333950
## 2025.50 7393561 6671869 8115253 6289828 8497293
## 2026.00 7460689 6681136 8240243 6268465 8652913
## 2026.50 7527818 6694400 8361236 6253215 8802421
## 2027.00 7594947 6710931 8478963 6242961 8946933
## 2027.50 7662075 6730195 8593956 6236888 9087263
autoplot(ts.pa3, color = "white", lwd = 2) +
autolayer(fitp3.holt$fitted, color = "blue")
fitp3.hw<-hw(ts.pa3,h=10)
# autoplot(fit3.hw)
# summary(fit3.hw)
# checkresiduals(fit3.hw)
autoplot(ts.pa3, color = "white", lwd = 2) +
autolayer(fitp3.hw$fitted, color = "blue")
####ARIMA
acf(ts.pa3)
pacf(ts.pa3)
fitp3.arima<-auto.arima(ts.pa3)
# autoplot(fit3.arima)
# summary(fit3.arima)
# checkresiduals(fit3.arima)
autoplot(ts.pa3, color = "white", lwd = 2) +
autolayer(fitp3.arima$fitted, color = "blue")
forecast(fitp3.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 7107615 6862269 7352962 6732390 7482841
## 2023.50 7224412 6877439 7571385 6693763 7755061
## 2024.00 7341208 6916255 7766161 6691299 7991118
## 2024.50 7458005 6967311 7948698 6707554 8208456
## 2025.00 7574801 7026189 8123413 6735771 8413831
## 2025.50 7691598 7090623 8292572 6772486 8610709
## 2026.00 7808394 7159267 8457521 6815640 8801147
## 2026.50 7925190 7231245 8619136 6863892 8986488
## 2027.00 8041987 7305946 8778027 6916310 9167663
## 2027.50 8158783 7382929 8934638 6972216 9345351
#### Model comparison
autoplot(ts.pa3, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fitp3.ets$fitted, color = "red")+autolayer (fitp3.arima$fitted, color = "blue")+autolayer(fitp3.holt$fitted, color = "red")+autolayer (fitp3.hw$fitted, color = "blue")
grid.arrange(autoplot(forecast(fitp3.ets,h=5)), autoplot(forecast(fitp3.arima,h=5)),autoplot(forecast(fitp3.holt,h=5)),autoplot(forecast(fitp3.hw,h=5)))
fp3.ets <- function (y,h) forecast(fitp3.ets,h=h)
fp3.arima <- function (y,h) forecast(fitp3.arima,h=h)
fp3.holt<- function (y,h) forecast(fitp3.holt,h=h)
fp3.hw<- function (y,h) forecast(fitp3.hw,h=h)
hmax<-5
ep3.ets<-na.omit(tsCV(ts.pa3,fp3.ets,h=hmax))[,hmax]
ep3.arima<-na.omit(tsCV(ts.pa3,fp3.arima,h=hmax))[,hmax]
ep3.holt<-na.omit(tsCV(ts.pa3,fp3.holt,h=hmax))[,hmax]
ep3.hw<-na.omit(tsCV(ts.pa3,fp3.hw,h=hmax))[,hmax]
summary(data.frame(ep3.ets^2,ep3.arima^2,ep3.holt^2,ep3.hw^2))
## ep3.ets.2 ep3.arima.2 ep3.holt.2
## Min. : 1380 Min. : 341035099270 Min. : 112636093891
## 1st Qu.:1006273687180 1st Qu.:2508247374430 1st Qu.:1786129605790
## Median :2172360131920 Median :4235002233000 Median :3274445912640
## Mean :2016497519980 Mean :3877219090460 Mean :3002534628930
## 3rd Qu.:3268056540790 3rd Qu.:5720142538250 3rd Qu.:4593965262020
## Max. :3511290772450 Max. :6041091044220 Max. :4881863789510
## ep3.hw.2
## Min. : 537075873923
## 1st Qu.:3000223308090
## Median :4869898298450
## Mean :4460643540720
## 3rd Qu.:6454311849030
## Max. :6795070520970
a<- read.xlsx("C:/Users/wassi/OneDrive/Bureau/Bilanc.xlsx")
p3<-ts(rev(a$pa3),start=2015,frequency=1)
r<-holt(p3)
grid.arrange(autoplot(t3, color = "white", lwd = 2) +
autolayer(r$fitted, color = "blue"),autoplot(ts.pa3, color = "white", lwd = 2) +
autolayer(fitp3.ets$fitted, color = "blue"))
vp3<-fitp3.ets$fitted
e3p<-abs(vp3-ts.pa3)/ts.pa3
summary(e3p)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0009 0.0148 0.0266 0.0336 0.0439 0.0874
mean(e3p)
## [1] 0.0336
#####visualisation
ts.ac12<-ts(rev(b$ac1+b$ac2),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.ac12)
#### ETS
fitac12.ets<-ets(ts.ac12,lambda="auto")
# autoplot(fit3.ets)
summary(fitac12.ets)
## ETS(A,N,N)
##
## Call:
## ets(y = ts.ac12, lambda = "auto")
##
## Box-Cox transformation: lambda= -0.726
##
## Smoothing parameters:
## alpha = 0.8996
##
## Initial states:
## l = 1.3774
##
## sigma: 0
##
## AIC AICc BIC
## -366 -365 -363
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -60.7 189698 146491 -4.83 25.2 0.837 -0.323
# checkresiduals(fit3.ets)
autoplot(ts.ac12, color = "white", lwd = 2) +
autolayer(fitac12.ets$fitted, color = "blue")
# forecast.ets(fitac12.ets,h=10)
#flat prediction
fitac12.holt<-holt(ts.ac12,damped=TRUE,initial="simple",)
## Warning in holt(ts.ac12, damped = TRUE, initial = "simple", ): Damped Holt's
## method requires optimal initialization
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
# summary(fit12.holt)
# checkresiduals(fit12.holt)
forecast(fitac12.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 648734 379025 918442 236250 1061218
## 2023.50 649987 329227 970746 159428 1140546
## 2024.00 651214 286469 1015960 93384 1209044
## 2024.50 652417 248436 1056399 34581 1270253
## 2025.00 653596 213857 1093336 -18928 1326120
## 2025.50 654752 181941 1127562 -68349 1377853
## 2026.00 655884 152161 1159607 -114494 1426262
## 2026.50 656994 124141 1189847 -157934 1471922
## 2027.00 658081 97604 1218559 -199095 1515258
## 2027.50 659147 72337 1245957 -238301 1556596
autoplot(ts.ac12, color = "white", lwd = 2) +
autolayer(fitac12.holt$fitted, color = "blue")
fitac12.hw<-hw(ts.ac12,h=10)
# autoplot(fit3.hw)
#summary(fit3.hw)
# checkresiduals(fit3.hw)
forecast(fitac12.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 648734 379025 918442 236250 1061218
## 2023.50 649987 329227 970746 159428 1140546
## 2024.00 651214 286469 1015960 93384 1209044
## 2024.50 652417 248436 1056399 34581 1270253
## 2025.00 653596 213857 1093336 -18928 1326120
## 2025.50 654752 181941 1127562 -68349 1377853
## 2026.00 655884 152161 1159607 -114494 1426262
## 2026.50 656994 124141 1189847 -157934 1471922
## 2027.00 658081 97604 1218559 -199095 1515258
## 2027.50 659147 72337 1245957 -238301 1556596
autoplot(ts.ac12, color = "white", lwd = 2) +
autolayer(fitac12.hw$fitted, color = "blue")
# flat predictions
####ARIMA
acf(ts.ac12)
pacf(ts.ac12)
fitac12.arima<-auto.arima(ts.ac12)
# autoplot(fit3.arima)
summary(fitac12.arima)
## Series: ts.ac12
## ARIMA(0,1,0)
##
## sigma^2 = 40808921415: log likelihood = -259
## AIC=520 AICc=520 BIC=521
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -5947 196897 148376 -5.58 25.6 0.848 -0.406
# checkresiduals(fit3.arima)
autoplot(ts.ac12, color = "white", lwd = 2) +
autolayer(fitac12.arima$fitted, color = "blue")
forecast(fitac12.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 587954 329065 846843 192017 983891
## 2023.50 587954 221830 954078 28015 1147893
## 2024.00 587954 139545 1036363 -97828 1273736
## 2024.50 587954 70176 1105732 -203919 1379827
## 2025.00 587954 9061 1166847 -297387 1473295
## 2025.50 587954 -46192 1222100 -381889 1557797
## 2026.00 587954 -97002 1272910 -459596 1635504
## 2026.50 587954 -144295 1320203 -531924 1707832
## 2027.00 587954 -188713 1364621 -599856 1775764
## 2027.50 587954 -230725 1406633 -664107 1840015
fitac12.TBATS<-tbats(ts.ac12)
# autoplot(fit3.TBATS)
# summary(fitac12.TBATS)
# checkresiduals(fit3.TBATS)
autoplot(ts.ac12, color = "white", lwd = 2) +
autolayer(fitac12.TBATS$fitted, color = "blue")
# Gives flat predictions, no good
v12<-fitac12.arima$fitted
er12<-abs(v12-ts.ac12)/ts.ac12
summary(er12)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.001 0.062 0.246 0.256 0.354 0.827
mean(er12)
## [1] 0.256
#### Model comparison
autoplot(ts.ac12, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fitac12.ets$fitted, color = "red")+autolayer (fitac12.arima$fitted, color = "blue")+autolayer(fitac12.holt$fitted, color = "red")+autolayer(fitac12.hw$fitted, color = "white")
grid.arrange(autoplot(forecast(fitac12.ets,h=10)), autoplot(forecast(fitac12.arima,h=5)),autoplot(forecast(fitac12.holt,h=5)))
f12.ets <- function (y,h) forecast(fitac12.ets,h=h)
f12.arima <- function (y,h) forecast(fitac12.arima,h=h)
f12.holt<- function (y,h) forecast(fitac12.holt,h=h)
f12.hw<- function (y,h) forecast(fitac12.holt,h=h)
hmax<-5
e12.ets<-na.omit(tsCV(ts.ac12,f12.ets,h=hmax))[,hmax]
e12.arima<-na.omit(tsCV(ts.ac12,f12.arima,h=hmax))[,hmax]
e12.holt<-na.omit(tsCV(ts.ac12,f12.holt,h=hmax))[,hmax]
e12.hw<-na.omit(tsCV(ts.ac12,f12.hw,h=hmax))[,hmax]
summary(data.frame(e12.ets^2,e12.arima^2,e12.holt^2,e12.hw^2))
## e12.ets.2 e12.arima.2 e12.holt.2
## Min. : 229110459 Min. : 0 Min. : 19128294
## 1st Qu.: 5114844650 1st Qu.: 6008159640 1st Qu.: 9895712486
## Median : 55607957343 Median : 49087504249 Median : 81978804270
## Mean : 63708925863 Mean : 62694220349 Mean : 70410057350
## 3rd Qu.:103625157816 3rd Qu.: 94109823508 3rd Qu.:129916843360
## Max. :182120346251 Max. :195268539664 Max. :173953565535
## e12.hw.2
## Min. : 19128294
## 1st Qu.: 9895712486
## Median : 81978804270
## Mean : 70410057350
## 3rd Qu.:129916843360
## Max. :173953565535
library(bsts) # Bayesian Structural Time Series: Time series regression using dynamic linear models fit using MCMC
## Le chargement a nécessité le package : BoomSpikeSlab
## Le chargement a nécessité le package : Boom
##
## Attachement du package : 'Boom'
## L'objet suivant est masqué depuis 'package:stats':
##
## rWishart
##
## Attachement du package : 'BoomSpikeSlab'
## L'objet suivant est masqué depuis 'package:stats':
##
## knots
## Le chargement a nécessité le package : xts
##
## ######################### Warning from 'xts' package ##########################
## # #
## # The dplyr lag() function breaks how base R's lag() function is supposed to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
## # source() into this session won't work correctly. #
## # #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## # #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## ###############################################################################
##
## Attachement du package : 'xts'
## Les objets suivants sont masqués depuis 'package:dplyr':
##
## first, last
##
## Attachement du package : 'bsts'
## L'objet suivant est masqué depuis 'package:BoomSpikeSlab':
##
## SuggestBurn
library(rstan)
## Le chargement a nécessité le package : StanHeaders
##
## rstan version 2.26.22 (Stan version 2.26.1)
## For execution on a local, multicore CPU with excess RAM we recommend calling
## options(mc.cores = parallel::detectCores()).
## To avoid recompilation of unchanged Stan programs, we recommend calling
## rstan_options(auto_write = TRUE)
## For within-chain threading using `reduce_sum()` or `map_rect()` Stan functions,
## change `threads_per_chain` option:
## rstan_options(threads_per_chain = 1)
## Do not specify '-march=native' in 'LOCAL_CPPFLAGS' or a Makevars file
##
## Attachement du package : 'rstan'
## L'objet suivant est masqué depuis 'package:strucchange':
##
## monitor
## L'objet suivant est masqué depuis 'package:tidyr':
##
## extract
phi1_prior <- rnorm(0, 20)
ss<- AddAr(
state.specification = list(phi1 = phi1_prior),lags=1,
y = ts.ac12,
sigma.prior = rexp(1) #Cauchy(1,0)
)
# arima_state <- AddAr(list(order = arima_order), y = ts.ac45)
ss<- AddLocalLinearTrend(list(), y = ts.ac12)
fitac12.stan<- bsts(ts.ac12,state.specification = ss, niter=500)
## =-=-=-=-= Iteration 0 Fri Sep 1 15:24:35 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 50 Fri Sep 1 15:24:35 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 100 Fri Sep 1 15:24:35 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 150 Fri Sep 1 15:24:35 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 200 Fri Sep 1 15:24:35 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 250 Fri Sep 1 15:24:35 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 300 Fri Sep 1 15:24:35 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 350 Fri Sep 1 15:24:35 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 400 Fri Sep 1 15:24:35 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 450 Fri Sep 1 15:24:35 2023
## =-=-=-=-=
predac12<- predict(fitac12.stan, horizon =10 , burn = 100)
# plot(pred)
# plot(forecast(fitac45.hw))
ts.predac12<-ts(predac12$mean,start=c(2023, 1),frequency=2)
autoplot(ts.predac12, color = "black") + autolayer(fitac12.hw$mean, color = "red")+
labs(title = "STAN predictions vs. HW predictions")
#####visualisation
ts.ac45<-ts(rev(b$ac4+b$ac5),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.ac45)
# plot(decompose(ts.pa3))
fitac45.ets<-ets(ts.ac45,lambda = TRUE)
# autoplot(fit3.ets)
summary(fit3.ets)
## ETS(M,A,N)
##
## Call:
## ets(y = ts.ac3)
##
## Smoothing parameters:
## alpha = 0.9999
## beta = 0.9999
##
## Initial states:
## l = 5593006.545
## b = 56751.8188
##
## sigma: 0.0292
##
## AIC AICc BIC
## 548 552 553
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 14593 154178 120839 0.243 2.05 0.465 0.0858
# checkresiduals(fit3.ets)
autoplot(ts.ac45, color = "white", lwd = 2) +
autolayer(fitac45.ets$fitted, color = "blue")
forecast.ets(fitac45.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 2441688 2303368 2580008 2230145 2653231
## 2023.50 2515083 2308674 2721492 2199408 2830758
## 2024.00 2588478 2322274 2854681 2181355 2995600
## 2024.50 2661872 2338832 2984913 2167824 3155920
## 2025.00 2735267 2356425 3114110 2155878 3314657
## 2025.50 2808662 2374142 3243182 2144121 3473202
## 2026.00 2882057 2391489 3372624 2131798 3632315
## 2026.50 2955451 2408173 3502730 2118462 3792441
## 2027.00 3028846 2424014 3633678 2103836 3953857
## 2027.50 3102241 2438897 3765585 2087744 4116738
#flat prediction
fitac45.holt<-holt(ts.ac45)
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
summary(fitac45.holt)
##
## Forecast method: Holt's method
##
## Model Information:
## Holt's method
##
## Call:
## holt(y = ts.ac45)
##
## Smoothing parameters:
## alpha = 0.9999
## beta = 0.1077
##
## Initial states:
## l = 858036.7704
## b = 119775.3988
##
## sigma: 107932
##
## AIC AICc BIC
## 529 533 534
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -21535 96537 74079 -1.41 4.27 0.395 0.0806
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 2441695 2303375 2580015 2230152 2653238
## 2023.50 2515097 2308693 2721501 2199429 2830764
## 2024.00 2588498 2322307 2854689 2181394 2995603
## 2024.50 2661900 2338881 2984919 2167885 3155915
## 2025.00 2735302 2356491 3114112 2155961 3314642
## 2025.50 2808703 2374227 3243179 2144230 3473177
## 2026.00 2882105 2391595 3372615 2131934 3632276
## 2026.50 2955507 2408300 3502713 2118627 3792386
## 2027.00 3028908 2424164 3633653 2104032 3953785
## 2027.50 3102310 2439070 3765550 2087973 4116647
# checkresiduals(fit12.holt)
forecast(fitac45.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 2441695 2303375 2580015 2230152 2653238
## 2023.50 2515097 2308693 2721501 2199429 2830764
## 2024.00 2588498 2322307 2854689 2181394 2995603
## 2024.50 2661900 2338881 2984919 2167885 3155915
## 2025.00 2735302 2356491 3114112 2155961 3314642
## 2025.50 2808703 2374227 3243179 2144230 3473177
## 2026.00 2882105 2391595 3372615 2131934 3632276
## 2026.50 2955507 2408300 3502713 2118627 3792386
## 2027.00 3028908 2424164 3633653 2104032 3953785
## 2027.50 3102310 2439070 3765550 2087973 4116647
autoplot(ts.ac45, color = "white", lwd = 2) +
autolayer(fitac45.holt$fitted, color = "blue")
fitac45.hw<-hw(ts.ac45,h=10)
# autoplot(fit3.hw)
summary(fitac45.hw)
##
## Forecast method: Holt-Winters' additive method
##
## Model Information:
## Holt-Winters' additive method
##
## Call:
## hw(y = ts.ac45, h = 10)
##
## Smoothing parameters:
## alpha = 0.9999
## beta = 0.1076
## gamma = 0.0001
##
## Initial states:
## l = 857229.6935
## b = 119908.7141
## s = -2196 2196
##
## sigma: 115425
##
## AIC AICc BIC
## 533 542 540
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -21480 96572 73475 -1.4 4.21 0.391 0.0809
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 2446369 2298445 2594292 2220139 2672599
## 2023.50 2515678 2294952 2736403 2178108 2853248
## 2024.00 2593748 2309088 2878407 2158399 3029097
## 2024.50 2663057 2317642 3008471 2134790 3191323
## 2025.00 2741126 2336060 3146193 2121631 3360622
## 2025.50 2810435 2345863 3275008 2099933 3520938
## 2026.00 2888505 2364027 3412983 2086385 3690626
## 2026.50 2957814 2372732 3542896 2063009 3852620
## 2027.00 3035884 2389293 3682475 2047009 4024759
## 2027.50 3105193 2396078 3814308 2020696 4189691
# checkresiduals(fit3.hw)
autoplot(ts.ac45, color = "white", lwd = 2) +
autolayer(fitac45.hw$fitted, color = "blue")
####ARIMA
acf(ts.ac45)
pacf(ts.ac45)
fitac45.arima<-auto.arima(ts.ac45)
# autoplot(fit3.arima)
summary(fitac45.arima)
## Series: ts.ac45
## ARIMA(0,1,0) with drift
##
## Coefficients:
## drift
## 77782
## s.e. 21416
##
## sigma^2 = 9197936207: log likelihood = -244
## AIC=493 AICc=494 BIC=495
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 40.6 90984 73627 0.266 4.1 0.392 0.15
# checkresiduals(fit3.arima)
autoplot(ts.ac45, color = "white", lwd = 2) +
autolayer(fitac45.arima$fitted, color = "blue")
forecast(fitac45.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 2446081 2323172 2568989 2258109 2634053
## 2023.50 2523862 2350044 2697681 2258030 2789695
## 2024.00 2601644 2388760 2814527 2276067 2927221
## 2024.50 2679426 2433609 2925242 2303481 3055370
## 2025.00 2757207 2482376 3032039 2336889 3177525
## 2025.50 2834989 2533926 3136051 2374553 3295424
## 2026.00 2912770 2587586 3237955 2415443 3410098
## 2026.50 2990552 2642915 3338189 2458887 3522217
## 2027.00 3068334 2699609 3437059 2504418 3632250
## 2027.50 3146115 2757445 3534786 2551695 3740535
#### Model comparison
autoplot(ts.ac45, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fitac45.ets$fitted, color = "red")+autolayer (fitac45.arima$fitted, color = "blue")+autolayer(fitac45.holt$fitted, color = "red")+autolayer (fitac45.hw$fitted, color = "blue")
grid.arrange(autoplot(forecast(fitac45.ets,h=5)), autoplot(forecast(fitac45.arima,h=5)),autoplot(forecast(fitac45.holt,h=5)),autoplot(forecast(fitac45.hw,h=5)))
fac45.ets <- function (y,h) forecast(fitac45.ets,h=h)
fac45.arima <- function (y,h) forecast(fitac45.arima,h=h)
fac45.holt<- function (y,h) forecast(fitac45.holt,h=h)
fac45.hw<- function (y,h) forecast(fitac45.hw,h=h)
hmax<-5
eac45.ets<-na.omit(tsCV(ts.pa3,fac45.ets,h=hmax))[,hmax]
eac45.arima<-na.omit(tsCV(ts.pa3,fac45.arima,h=hmax))[,hmax]
eac45.holt<-na.omit(tsCV(ts.pa3,fac45.holt,h=hmax))[,hmax]
eac45.hw<-na.omit(tsCV(ts.pa3,fac45.hw,h=hmax))[,hmax]
summary(data.frame(eac45.ets^2,eac45.arima^2,eac45.holt^2,eac45.hw^2))
## eac45.ets.2 eac45.arima.2 eac45.holt.2
## Min. : 5672356329780 Min. : 5568329647180 Min. : 5672191786270
## 1st Qu.: 5995394936330 1st Qu.: 5888448732590 1st Qu.: 5995225796120
## Median : 7737420457480 Median : 7615843869640 Median : 7737228282190
## Mean : 9052872001800 Mean : 8923709790080 Mean : 9052667883180
## 3rd Qu.:10656700526900 3rd Qu.:10514061099600 3rd Qu.:10656475188800
## Max. :18109722069900 Max. :17923469229600 Max. :18109428063800
## eac45.hw.2
## Min. : 5644480979760
## 1st Qu.: 5966739905650
## Median : 7704858269840
## Mean : 9018284014760
## 3rd Qu.:10618513345500
## Max. :18059887589900
a<- read.xlsx("C:/Users/wassi/OneDrive/Bureau/Bilanc.xlsx")
a45<-ts(rev(a$ac4+a$ac5),start=2015,frequency=1)
r<-ets(a45)
grid.arrange(autoplot(a45, color = "white", lwd = 2) +
autolayer(r$fitted, color = "blue"),autoplot(ts.ac45, color = "white", lwd = 2) +
autolayer(fitac45.hw$fitted, color = "blue"))
v45<-fitac45.arima$fitted
e45a<-abs(v45-ts.ac45)/ts.ac45
summary(e45a)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0009 0.0200 0.0288 0.0410 0.0587 0.1133
mean(e45a)
## [1] 0.041
library(bsts) # Bayesian Structural Time Series: Time series regression using dynamic linear models fit using MCMC
library(rstan)
phi1_prior <- rnorm(0, 20)
ss<- AddAr(
state.specification = list(phi1 = phi1_prior),lags=1,
y = ts.ac45,
sigma.prior = rexp(1) #Cauchy(1,0)
)
# arima_state <- AddAr(list(order = arima_order), y = ts.ac45)
ss<- AddLocalLinearTrend(list(), y = ts.ac45)
fitac45.stan<- bsts(ts.ac45,state.specification = ss, niter=500)
## =-=-=-=-= Iteration 0 Fri Sep 1 15:24:45 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 50 Fri Sep 1 15:24:45 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 100 Fri Sep 1 15:24:45 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 150 Fri Sep 1 15:24:45 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 200 Fri Sep 1 15:24:45 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 250 Fri Sep 1 15:24:45 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 300 Fri Sep 1 15:24:45 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 350 Fri Sep 1 15:24:45 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 400 Fri Sep 1 15:24:45 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 450 Fri Sep 1 15:24:45 2023
## =-=-=-=-=
predac45<- predict(fitac45.stan, horizon =10 , burn = 100)
# plot(pred)
# plot(forecast(fitac45.hw))
ts.predac45<-ts(predac45$mean,start=c(2023, 1),frequency=2)
autoplot(ts.predac45, color = "black") + autolayer(fitac45.hw$mean, color = "red")+
labs(title = "STAN predictions vs. HW predictions")
#####visualisation
ts.ac6<-ts(rev(b$ac6),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.ac6)
# plot(decompose(ts.pa3))
fitac6.ets<-ets(ts.ac6)
# autoplot(fit3.ets)
#summary(fit3.ets)
# checkresiduals(fit3.ets)
autoplot(ts.ac6, color = "white", lwd = 2) +
autolayer(fitac6.ets$fitted, color = "blue")
forecast.ets(fitac6.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 433642 371635 495650 338810 528475
## 2023.50 501829 404685 598972 353260 650397
## 2024.00 570015 421382 718648 342700 797330
## 2024.50 638201 423372 853030 309648 966754
## 2025.00 706387 411165 1001610 254883 1157892
## 2025.50 774574 384586 1164561 178139 1371008
## 2026.00 842760 343083 1342437 78569 1606950
## 2026.50 910946 285848 1536044 -45058 1866950
## 2027.00 979132 211877 1746388 -194284 2152548
## 2027.50 1047319 119977 1974660 -370928 2465565
fitac6.holt<-holt(ts.ac6)
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
# summary(fit12.holt)
# checkresiduals(fit12.holt)
forecast(fitac6.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 437485 408881 466089 393738 481232
## 2023.50 507240 464292 550187 441557 572922
## 2024.00 576994 512546 641443 478429 675559
## 2024.50 646749 555872 737626 507765 785733
## 2025.00 716504 595372 837635 531249 901758
## 2025.50 786258 631633 940884 549779 1022738
## 2026.00 856013 665013 1047013 563904 1148122
## 2026.50 925768 695765 1155770 574009 1277526
## 2027.00 995522 724076 1266969 580381 1410663
## 2027.50 1065277 750095 1380459 583248 1547306
autoplot(ts.ac6, color = "white", lwd = 2) +
autolayer(fitac6.holt$fitted, color = "blue")
fitac6.hw<-hw(ts.ac6,h=10)
# autoplot(fit3.hw)
# summary(fit3.hw)
# checkresiduals(fit3.hw)
autoplot(ts.ac6, color = "white", lwd = 2) +
autolayer(fitac6.hw$fitted, color = "blue")
####ARIMA
acf(ts.ac6)
pacf(ts.ac6)
fitac6.arima<-auto.arima(ts.ac6)
# autoplot(fit3.arima)
# summary(fit3.arima)
# checkresiduals(fit3.arima)
autoplot(ts.ac6, color = "white", lwd = 2) +
autolayer(fitac6.arima$fitted, color = "blue")
forecast(fitac6.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 498135 467885 528385 451871 544399
## 2023.50 598797 531156 666438 495348 702246
## 2024.00 699459 586273 812645 526357 872561
## 2024.50 800121 634434 965808 546725 1053517
## 2025.00 900783 676442 1125124 557683 1243883
## 2025.50 1001445 712877 1290013 560119 1442771
## 2026.00 1102107 744183 1460031 554709 1649505
## 2026.50 1202769 770711 1634827 541993 1863545
## 2027.00 1303431 792750 1814112 522412 2084450
## 2027.50 1404093 810543 1997643 496336 2311850
fitac6.TBATS<-tbats(ts.ac6)
autoplot(fitac6.TBATS)
summary(fitac6.TBATS)
## Length Class Mode
## lambda 1 -none- numeric
## alpha 1 -none- numeric
## beta 1 -none- numeric
## damping.parameter 1 -none- numeric
## gamma.values 0 -none- NULL
## ar.coefficients 0 -none- NULL
## ma.coefficients 0 -none- NULL
## likelihood 1 -none- numeric
## optim.return.code 1 -none- numeric
## variance 1 -none- numeric
## AIC 1 -none- numeric
## parameters 2 -none- list
## seed.states 2 -none- numeric
## fitted.values 20 ts numeric
## errors 20 ts numeric
## x 40 -none- numeric
## seasonal.periods 0 -none- NULL
## y 20 ts numeric
## call 2 -none- call
## series 1 -none- character
## method 1 -none- character
checkresiduals(fitac6.TBATS)
##
## Ljung-Box test
##
## data: Residuals from TBATS
## Q* = 0.8, df = 4, p-value = 0.9
##
## Model df: 0. Total lags used: 4
autoplot(ts.ac6, color = "white", lwd = 2) +
autolayer(fitac6.TBATS$fitted, color = "blue")
#### Model comparison
autoplot(ts.ac6, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fitac6.ets$fitted, color = "red")+autolayer (fitac6.arima$fitted, color = "blue")+autolayer(fitac6.holt$fitted, color = "white")+autolayer (fitac6.hw$fitted, color = "yellow")+autolayer (fitac6.TBATS$fitted, color = "green")
grid.arrange(autoplot(forecast(fitac6.ets,h=5)), autoplot(forecast(fitac6.arima,h=5)),autoplot(forecast(fitac6.holt,h=5)),autoplot(forecast(fitac6.hw,h=5)),autoplot(forecast(fitac6.TBATS,h=5)))
fac6.ets <- function (y,h) forecast(fitac6.ets,h=h)
fac6.arima <- function (y,h) forecast(fitac6.arima,h=h)
fac6.holt<- function (y,h) forecast(fitac6.holt,h=h)
fac6.hw<- function (y,h) forecast(fitac6.hw,h=h)
fac6.TBATS<- function (y,h) forecast(fitac6.TBATS,h=h)
hmax<-5
eac6.ets<-na.omit(tsCV(ts.ac6,fac6.ets,h=hmax))[,hmax]
eac6.arima<-na.omit(tsCV(ts.ac6,fac6.arima,h=hmax))[,hmax]
eac6.holt<-na.omit(tsCV(ts.ac6,fac6.holt,h=hmax))[,hmax]
eac6.hw<-na.omit(tsCV(ts.ac6,fac6.hw,h=hmax))[,hmax]
eac6.TBATS<-na.omit(tsCV(ts.ac6,fac6.TBATS,h=hmax))[,hmax]
summary(data.frame(eac6.ets^2,eac6.arima^2,eac6.holt^2,eac6.hw^2,eac6.TBATS^2))
## eac6.ets.2 eac6.arima.2 eac6.holt.2
## Min. : 95428098320 Min. :253320956100 Min. :101780592948
## 1st Qu.:230116905059 1st Qu.:454266980484 1st Qu.:239917416446
## Median :281212136582 Median :525175596100 Median :292043733831
## Mean :265327454260 Mean :501229172179 Mean :275739519553
## 3rd Qu.:318125359719 3rd Qu.:575058700160 3rd Qu.:329631907840
## Max. :346710625453 Max. :613428869089 Max. :358726378629
## eac6.hw.2 eac6.TBATS.2
## Min. : 91195226218 Min. :104398692889
## 1st Qu.:223522402970 1st Qu.:243925162431
## Median :273911418874 Median :296467035915
## Mean :258314084126 Mean :279993738664
## 3rd Qu.:310362351852 3rd Qu.:334327233778
## Max. :338598850740 Max. :363626928277
vac6<-fitac6.hw$fitted
eac6<-abs(vac6-ts.ac6)/ts.ac6
summary(eac6)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0055 0.0181 0.0436 0.0719 0.1179 0.2066
mean(eac6)
## [1] 0.0719
#####visualisation
ts.ac7<-ts(rev(b$ac7),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.ac7)
# plot(decompose(ts.pa3))
fitac7.ets<-ets(ts.ac7)
# autoplot(fit3.ets)
#summary(fit3.ets)
# checkresiduals(fit3.ets)
autoplot(ts.ac7, color = "white", lwd = 2) +
autolayer(fitac7.ets$fitted, color = "blue")
forecast.ets(fitac7.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 178830 136778 220882 114517 243143
## 2023.50 178830 128089 229570 101229 256431
## 2024.00 178830 120685 236975 89905 267755
## 2024.50 178830 114122 243537 79868 277791
## 2025.00 178830 108167 249493 70760 286900
## 2025.50 178830 102675 254984 62362 295298
## 2026.00 178830 97554 260106 54529 303130
## 2026.50 178830 92737 264923 47162 310497
## 2027.00 178830 88176 269484 40186 317474
## 2027.50 178830 83833 273827 33545 324115
fitac7.holt<-holt(ts.ac7)
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
# summary(fit12.holt)
# checkresiduals(fit12.holt)
forecast(fitac7.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 203219 160982 245456 138623 267815
## 2023.50 209708 163740 255676 139405 280010
## 2024.00 216196 166777 265616 140615 291777
## 2024.50 222685 170038 275332 142168 303202
## 2025.00 229174 173485 284863 144005 314343
## 2025.50 235663 177088 294237 146081 325245
## 2026.00 242152 180826 303477 148362 335941
## 2026.50 248640 184680 312600 150822 346458
## 2027.00 255129 188638 321620 153440 356818
## 2027.50 261618 192688 330548 156198 367037
autoplot(ts.ac7, color = "white", lwd = 2) +
autolayer(fitac7.holt$fitted, color = "blue")
fitac7.hw<-hw(ts.ac7,h=10)
# autoplot(fit3.hw)
# summary(fit3.hw)
# checkresiduals(fit3.hw)
autoplot(ts.ac7, color = "white", lwd = 2) +
autolayer(fitac7.hw$fitted, color = "blue")
####ARIMA
acf(ts.ac7)
pacf(ts.ac7)
fitac7.arima<-auto.arima(ts.ac7)
# autoplot(fit3.arima)
summary(fitac7.arima)
## Series: ts.ac7
## ARIMA(0,1,0)
##
## sigma^2 = 1096276751: log likelihood = -225
## AIC=451 AICc=452 BIC=452
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 4971 32272 22232 2.31 13.6 0.723 -0.259
# checkresiduals(fit3.arima)
autoplot(ts.ac7, color = "white", lwd = 2) +
autolayer(fitac7.arima$fitted, color = "blue")
forecast(fitac7.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 163260 120828 205692 98365 228155
## 2023.50 163260 103252 223268 71485 255035
## 2024.00 163260 89765 236755 50859 275661
## 2024.50 163260 78395 248125 33471 293049
## 2025.00 163260 68379 258141 18151 308369
## 2025.50 163260 59323 267197 4301 322219
## 2026.00 163260 50995 275525 -8435 334955
## 2026.50 163260 43243 283277 -20289 346809
## 2027.00 163260 35963 290557 -31424 357944
## 2027.50 163260 29077 297443 -41955 368475
fitac7.TBATS<-tbats(ts.ac7)
autoplot(fitac7.TBATS)
summary(fitac7.TBATS)
## Length Class Mode
## lambda 0 -none- NULL
## alpha 1 -none- numeric
## beta 1 -none- numeric
## damping.parameter 1 -none- numeric
## gamma.values 0 -none- NULL
## ar.coefficients 0 -none- NULL
## ma.coefficients 0 -none- NULL
## likelihood 1 -none- numeric
## optim.return.code 1 -none- numeric
## variance 1 -none- numeric
## AIC 1 -none- numeric
## parameters 2 -none- list
## seed.states 2 -none- numeric
## fitted.values 20 ts numeric
## errors 20 ts numeric
## x 40 -none- numeric
## seasonal.periods 0 -none- NULL
## y 20 ts numeric
## call 2 -none- call
## series 1 -none- character
## method 1 -none- character
checkresiduals(fitac7.TBATS)
##
## Ljung-Box test
##
## data: Residuals from TBATS
## Q* = 2, df = 4, p-value = 0.7
##
## Model df: 0. Total lags used: 4
autoplot(ts.ac7, color = "white", lwd = 2) +
autolayer(fitac7.TBATS$fitted, color = "blue")
#### Model comparison
autoplot(ts.ac7, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fitac7.ets$fitted, color = "red")+autolayer (fitac7.arima$fitted, color = "blue")+autolayer(fitac7.holt$fitted, color = "white")+autolayer (fitac7.hw$fitted, color = "yellow")+autolayer (fitac7.TBATS$fitted, color = "green")
grid.arrange(autoplot(forecast(fitac7.ets,h=5)), autoplot(forecast(fitac7.arima,h=5)),autoplot(forecast(fitac7.holt,h=5)),autoplot(forecast(fitac7.hw,h=5)),autoplot(forecast(fitac7.TBATS,h=5)))
fac7.ets <- function (y,h) forecast(fitac7.ets,h=h)
fac7.arima <- function (y,h) forecast(fitac7.arima,h=h)
fac7.holt<- function (y,h) forecast(fitac7.holt,h=h)
fac7.hw<- function (y,h) forecast(fitac7.hw,h=h)
fac7.TBATS<- function (y,h) forecast(fitac7.TBATS,h=h)
hmax<-5
eac7.ets<-na.omit(tsCV(ts.ac7,fac7.ets,h=hmax))[,hmax]
eac7.arima<-na.omit(tsCV(ts.ac7,fac7.arima,h=hmax))[,hmax]
eac7.holt<-na.omit(tsCV(ts.ac7,fac7.holt,h=hmax))[,hmax]
eac7.hw<-na.omit(tsCV(ts.ac7,fac7.hw,h=hmax))[,hmax]
eac7.TBATS<-na.omit(tsCV(ts.ac7,fac7.TBATS,h=hmax))[,hmax]
summary(data.frame(eac7.ets^2,eac7.arima^2,eac7.holt^2,eac7.hw^2,eac7.TBATS^2))
## eac7.ets.2 eac7.arima.2 eac7.holt.2
## Min. : 710355 Min. : 0 Min. : 1990814
## 1st Qu.: 268388074 1st Qu.: 41487626 1st Qu.: 444279365
## Median : 541624421 Median : 216884529 Median : 2677955073
## Mean : 1487911576 Mean :1684382654 Mean : 4171015131
## 3rd Qu.: 1012137628 3rd Qu.:2245177125 3rd Qu.: 4913489818
## Max. :11284563431 Max. :8219054281 Max. :24515092445
## eac7.hw.2 eac7.TBATS.2
## Min. : 3381780 Min. : 2393859
## 1st Qu.: 462416246 1st Qu.: 287734305
## Median : 2722435334 Median : 980866594
## Mean : 4215555940 Mean : 2471036463
## 3rd Qu.: 4973672531 3rd Qu.: 2466859178
## Max. :24649301980 Max. :18534859211
vac7<-fitac7.arima$fitted
eac7<-abs(vac7-ts.ac7)/ts.ac7
summary(eac7)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.001 0.041 0.085 0.136 0.197 0.533
mean(eac7)
## [1] 0.136
library(bsts) # Bayesian Structural Time Series: Time series regression using dynamic linear models fit using MCMC
library(rstan)
phi1_prior <- rnorm(0, 20)
ss<- AddAr(
state.specification = list(phi1 = phi1_prior),lags=1,
y = ts.ac6,
sigma.prior = rexp(1) #Cauchy(1,0)
)
# arima_state <- AddAr(list(order = arima_order), y = ts.ac45)
ss<- AddLocalLinearTrend(list(), y = ts.ac6)
fitac6.stan<- bsts(ts.ac6,state.specification = ss, niter=500)
## =-=-=-=-= Iteration 0 Fri Sep 1 15:25:10 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 50 Fri Sep 1 15:25:10 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 100 Fri Sep 1 15:25:10 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 150 Fri Sep 1 15:25:10 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 200 Fri Sep 1 15:25:10 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 250 Fri Sep 1 15:25:10 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 300 Fri Sep 1 15:25:10 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 350 Fri Sep 1 15:25:10 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 400 Fri Sep 1 15:25:10 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 450 Fri Sep 1 15:25:10 2023
## =-=-=-=-=
predac6 <- predict(fitac6.stan, horizon =10 , burn = 100)
# plot(pred)
# plot(forecast(fitac45.hw))
ts.predac6<-ts(predac6$mean,start=c(2023, 1),frequency=2)
#####visualisation
ts.pa12<-ts(rev(b$pa1+b$pa2),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.pa12)
# plot(decompose(ts.pa3))
fitpa12.ets<-ets(ts.pa12)
# autoplot(fit3.ets)
summary(fitpa12.ets)
## ETS(A,N,N)
##
## Call:
## ets(y = ts.pa12)
##
## Smoothing parameters:
## alpha = 0.7857
##
## Initial states:
## l = 806035.4709
##
## sigma: 195876
##
## AIC AICc BIC
## 551 553 554
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 17061 185824 138524 -0.164 13 0.675 -0.0261
# checkresiduals(fit3.ets)
autoplot(ts.pa12, color = "white", lwd = 2) +
autolayer(fitpa12.ets$fitted, color = "blue")
forecast.ets(fitpa12.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 1074123 823098 1325148 690213 1458033
## 2023.50 1074123 754887 1393360 585893 1562353
## 2024.00 1074123 698877 1449370 500233 1648013
## 2024.50 1074123 650203 1498043 425794 1722453
## 2025.00 1074123 606570 1541677 359062 1789185
## 2025.50 1074123 566674 1581572 298047 1850199
## 2026.00 1074123 529695 1618552 241491 1906755
## 2026.50 1074123 495072 1653175 188540 1959706
## 2027.00 1074123 462405 1685841 138581 2009665
## 2027.50 1074123 431397 1716849 91158 2057088
fitpa12.holt<-holt(ts.pa12)
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
# summary(fit12.holt)
# checkresiduals(fit12.holt)
forecast(fitpa12.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 1063870 776219 1351522 623946 1503795
## 2023.50 1056791 685593 1427990 489092 1624490
## 2024.00 1049712 591627 1507798 349131 1750294
## 2024.50 1042633 493823 1591444 203301 1881966
## 2025.00 1035554 392029 1679080 51367 2019742
## 2025.50 1028475 286231 1770719 -106689 2163640
## 2026.00 1021396 176480 1866312 -270791 2313583
## 2026.50 1014317 62855 1965780 -440819 2469454
## 2027.00 1007238 -54557 2069033 -616637 2631113
## 2027.50 1000159 -175660 2175978 -798101 2798419
autoplot(ts.pa12, color = "white", lwd = 2) +
autolayer(fitpa12.holt$fitted, color = "blue")
fitpa12.hw<-hw(ts.pa12,h=10)
# autoplot(fit3.hw)
# summary(fit3.hw)
# checkresiduals(fit3.hw)
autoplot(ts.pa12, color = "white", lwd = 2) +
autolayer(fitpa12.hw$fitted, color = "blue")
####ARIMA
acf(ts.pa12)
pacf(ts.pa12)
fitpa12.arima<-auto.arima(ts.pa12)
# autoplot(fit3.arima)
# summary(fit3.arima)
# checkresiduals(fit3.arima)
autoplot(ts.pa12, color = "white", lwd = 2) +
autolayer(fitpa12.arima$fitted, color = "blue")
forecast(fitpa12.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 1060664 818249 1303079 689922 1431406
## 2023.50 1062801 764106 1361497 605986 1519616
## 2024.00 1064340 740302 1388379 568766 1559915
## 2024.50 1065448 729026 1401870 550935 1579961
## 2025.00 1066246 723582 1408909 542187 1590304
## 2025.50 1066820 720966 1412673 537883 1595757
## 2026.00 1067233 719738 1414728 535785 1598681
## 2026.50 1067531 719188 1415874 534786 1600275
## 2027.00 1067745 718963 1416526 534330 1601160
## 2027.50 1067899 718891 1416908 534137 1601662
fitpa12.TBATS<-tbats(ts.pa12)
autoplot(fitpa12.TBATS)
summary(fitpa12.TBATS)
## Length Class Mode
## lambda 0 -none- NULL
## alpha 1 -none- numeric
## beta 0 -none- NULL
## damping.parameter 0 -none- NULL
## gamma.values 0 -none- NULL
## ar.coefficients 0 -none- NULL
## ma.coefficients 0 -none- NULL
## likelihood 1 -none- numeric
## optim.return.code 1 -none- numeric
## variance 1 -none- numeric
## AIC 1 -none- numeric
## parameters 2 -none- list
## seed.states 1 -none- numeric
## fitted.values 20 ts numeric
## errors 20 ts numeric
## x 20 -none- numeric
## seasonal.periods 0 -none- NULL
## y 20 ts numeric
## call 2 -none- call
## series 1 -none- character
## method 1 -none- character
checkresiduals(fitpa12.TBATS)
##
## Ljung-Box test
##
## data: Residuals from TBATS
## Q* = 1, df = 4, p-value = 0.9
##
## Model df: 0. Total lags used: 4
autoplot(ts.pa12, color = "white", lwd = 2) +
autolayer(fitpa12.TBATS$fitted, color = "blue")
#### Model comparison
autoplot(ts.pa12, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fitpa12.ets$fitted, color = "red")+autolayer (fitpa12.arima$fitted, color = "blue")+autolayer(fitpa12.holt$fitted, color = "white")+autolayer (fitpa12.hw$fitted, color = "yellow")+autolayer (fitpa12.TBATS$fitted, color = "green")
grid.arrange(autoplot(forecast(fitpa12.ets,h=5)), autoplot(forecast(fitpa12.arima,h=5)),autoplot(forecast(fitpa12.holt,h=5)),autoplot(forecast(fitpa12.hw,h=5)),autoplot(forecast(fitpa12.TBATS,h=5)))
fpa12.ets <- function (y,h) forecast(fitpa12.ets,h=h)
fpa12.arima <- function (y,h) forecast(fitpa12.arima,h=h)
fpa12.holt<- function (y,h) forecast(fitpa12.holt,h=h)
fpa12.hw<- function (y,h) forecast(fitpa12.hw,h=h)
fpa12.TBATS<- function (y,h) forecast(fitpa12.TBATS,h=h)
hmax<-5
epa12.ets<-na.omit(tsCV(ts.pa12,fpa12.ets,h=hmax))[,hmax]
epa12.arima<-na.omit(tsCV(ts.pa12,fpa12.arima,h=hmax))[,hmax]
epa12.holt<-na.omit(tsCV(ts.pa12,fpa12.holt,h=hmax))[,hmax]
epa12.hw<-na.omit(tsCV(ts.pa12,fpa12.hw,h=hmax))[,hmax]
epa12.TBATS<-na.omit(tsCV(ts.pa12,fpa12.TBATS,h=hmax))[,hmax]
summary(data.frame(epa12.ets^2,epa12.arima^2,epa12.holt^2,epa12.hw^2,epa12.TBATS^2))
## epa12.ets.2 epa12.arima.2 epa12.holt.2
## Min. : 269920287 Min. : 73132581 Min. : 10631950
## 1st Qu.: 5412226854 1st Qu.: 5505013355 1st Qu.: 1995691492
## Median : 45342910840 Median : 44853207698 Median : 32795157384
## Mean : 56656178760 Mean : 58738078506 Mean : 68033084580
## 3rd Qu.: 61543476211 3rd Qu.: 65507201663 3rd Qu.: 82133972036
## Max. :236009169021 Max. :243725117221 Max. :274970889070
## epa12.hw.2 epa12.TBATS.2
## Min. : 1620873753 Min. : 194127850
## 1st Qu.: 7331712072 1st Qu.: 5460339469
## Median : 29488471528 Median : 46412249112
## Mean : 47786745443 Mean : 57302472494
## 3rd Qu.: 58466925201 3rd Qu.: 62786095833
## Max. :197661225226 Max. :238440818827
vpa12<-fitpa12.ets$fitted
epa12<-abs(vpa12-ts.pa12)/ts.pa12
summary(epa12)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.004 0.029 0.086 0.130 0.207 0.397
mean(epa12)
## [1] 0.13
library(bsts) # Bayesian Structural Time Series: Time series regression using dynamic linear models fit using MCMC
library(rstan)
phi1_prior <- rnorm(0, 20)
ss<- AddAr(
state.specification = list(phi1 = phi1_prior),lags=1,
y = ts.pa12,
sigma.prior = rexp(1) #Cauchy(1,0)
)
# arima_state <- AddAr(list(order = arima_order), y = ts.ac45)
ss<- AddLocalLinearTrend(list(), y = ts.pa12)
fitpa12.stan<- bsts(ts.pa12,state.specification = ss, niter=500)
## =-=-=-=-= Iteration 0 Fri Sep 1 15:25:23 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 50 Fri Sep 1 15:25:23 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 100 Fri Sep 1 15:25:23 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 150 Fri Sep 1 15:25:23 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 200 Fri Sep 1 15:25:23 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 250 Fri Sep 1 15:25:23 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 300 Fri Sep 1 15:25:23 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 350 Fri Sep 1 15:25:23 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 400 Fri Sep 1 15:25:23 2023
## =-=-=-=-=
## =-=-=-=-= Iteration 450 Fri Sep 1 15:25:24 2023
## =-=-=-=-=
predpa12 <- predict(fitpa12.stan, horizon =10 , burn = 100)
# plot(pred)
# plot(forecast(fitac45.hw))
ts.predpa12<-ts(predpa12$mean,start=c(2023, 1),frequency=2)
#####visualisation
ts.pa4<-ts(rev(b$pa4),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.pa4)
# plot(decompose(ts.pa3))
fitpa4.holt<-holt(ts.pa4)
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
# summary(fit12.holt)
# checkresiduals(fit12.holt)
forecast(fitpa4.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 825648 751422 899873 712130 939165
## 2023.50 822910 724237 921584 672002 973819
## 2024.00 820173 702001 938345 639445 1000902
## 2024.50 817436 682552 952320 611149 1023723
## 2025.00 814699 664953 964444 585683 1043715
## 2025.50 811962 648699 975224 562273 1061650
## 2026.00 809224 633478 984970 540444 1078005
## 2026.50 806487 619085 993889 519880 1093094
## 2027.00 803750 605373 1002127 500359 1107142
## 2027.50 801013 592235 1009791 481714 1120312
autoplot(ts.pa4, color = "white", lwd = 2) +
autolayer(fitpa4.holt$fitted, color = "blue")
fitpa4.hw<-hw(ts.pa4,h=10)
# autoplot(fit3.hw)
# summary(fit3.hw)
# checkresiduals(fit3.hw)
autoplot(ts.pa4, color = "white", lwd = 2) +
autolayer(fitpa4.hw$fitted, color = "blue")
forecast(fitpa4.hw)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 820704 740070 901338 697385 944023
## 2023.50 836705 723648 949763 663799 1009612
## 2024.00 830411 691216 969605 617531 1043291
## 2024.50 846412 684281 1008543 598455 1094369
## 2025.00 840117 657017 1023217 560090 1120145
## 2025.50 856119 653392 1058845 546075 1166162
## 2026.00 849824 628433 1071214 511236 1188411
## 2026.50 865825 626498 1105152 499805 1231845
## 2027.00 859530 602820 1116240 466926 1252134
## 2027.50 875532 601880 1149184 457017 1294046
####ARIMA
acf(ts.pa4)
pacf(ts.pa4)
fitpa4.arima<-auto.arima(ts.pa4)
# autoplot(fit3.arima)
summary(fitpa4.arima)
## Series: ts.pa4
## ARIMA(1,0,0) with non-zero mean
##
## Coefficients:
## ar1 mean
## 0.417 893831
## s.e. 0.211 16827
##
## sigma^2 = 2232894910: log likelihood = -243
## AIC=491 AICc=493 BIC=494
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 695 44829 36087 -0.175 4.04 0.602 0.115
# checkresiduals(fit3.arima)
autoplot(ts.pa4, color = "white", lwd = 2) +
autolayer(fitpa4.arima$fitted, color = "blue")
forecast(fitpa4.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 865387 804829 925945 772772 958002
## 2023.50 881982 816380 947584 781652 982312
## 2024.00 888895 822456 955333 787286 990504
## 2024.50 891775 825192 958357 789945 993604
## 2025.00 892974 826367 959582 791107 994842
## 2025.50 893474 826862 960086 791600 995348
## 2026.00 893682 827069 960295 791807 995558
## 2026.50 893769 827156 960382 791893 995644
## 2027.00 893805 827192 960418 791929 995681
## 2027.50 893820 827207 960433 791944 995696
#### Model comparison
autoplot(ts.pa4, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer (fitpa4.arima$fitted, color = "blue")+autolayer(fitpa4.holt$fitted, color = "white")+autolayer (fitpa4.hw$fitted, color = "green")
grid.arrange(autoplot(forecast(fitpa4.ets,h=5)), autoplot(forecast(fitpa4.arima,h=5)),autoplot(forecast(fitpa4.holt,h=5)),autoplot(forecast(fitpa4.hw,h=5)),autoplot(forecast(fitpa4.TBATS,h=5)))
fpa4.ets <- function (y,h) forecast(fitpa4.ets,h=h)
fpa4.arima <- function (y,h) forecast(fitpa4.arima,h=h)
fpa4.holt<- function (y,h) forecast(fitpa4.holt,h=h)
fpa4.hw<- function (y,h) forecast(fitpa4.hw,h=h)
fpa4.TBATS<- function (y,h) forecast(fitpa4.TBATS,h=h)
hmax<-5
epa4.ets<-na.omit(tsCV(ts.pa4,fpa4.ets,h=hmax))[,hmax]
epa4.arima<-na.omit(tsCV(ts.pa4,fpa4.arima,h=hmax))[,hmax]
epa4.holt<-na.omit(tsCV(ts.pa4,fpa4.holt,h=hmax))[,hmax]
epa4.hw<-na.omit(tsCV(ts.pa4,fpa4.hw,h=hmax))[,hmax]
epa4.TBATS<-na.omit(tsCV(ts.pa4,fpa4.TBATS,h=hmax))[,hmax]
summary(data.frame(epa4.ets^2,epa4.arima^2,epa4.holt^2,epa4.hw^2,epa4.TBATS^2))
## epa4.ets.2 epa4.arima.2 epa4.holt.2
## Min. : 148492851 Min. : 62587056 Min. : 93763
## 1st Qu.: 453061149 1st Qu.: 408952209 1st Qu.: 2188333023
## Median :3236445280 Median :2768359075 Median : 9444381412
## Mean :2908393522 Mean :2950259638 Mean :10178540047
## 3rd Qu.:5033882820 3rd Qu.:5092258086 3rd Qu.:16381094842
## Max. :7288418631 Max. :8036549085 Max. :28197867698
## epa4.hw.2 epa4.TBATS.2
## Min. : 58478 Min. : 128717035
## 1st Qu.: 947525645 1st Qu.: 417994050
## Median : 5150046043 Median :3141529973
## Mean : 6487759170 Mean :2913738607
## 3rd Qu.:10568341348 3rd Qu.:5077719767
## Max. :20307339076 Max. :7432620500
vpa4<-fitpa4.arima$fitted
epa4<-abs(vpa4-ts.pa4)/ts.pa4
summary(epa4)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0019 0.0180 0.0351 0.0404 0.0586 0.1042
mean(epa4)
## [1] 0.0404
#####visualisation
ts.pa5<-ts(rev(b$pa5),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.pa5)
# plot(decompose(ts.pa3))
fitpa5.ets<-ets(ts.pa5,alpha=0.38)
# autoplot(fit3.ets)
summary(fitpa5.ets)
## ETS(A,N,N)
##
## Call:
## ets(y = ts.pa5, alpha = 0.38)
##
## Smoothing parameters:
## alpha = 0.38
##
## Initial states:
## l = 169763.8711
##
## sigma: 39597
##
## AIC AICc BIC
## 485 486 487
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 7834 37565 29213 1.11 14.6 0.729 -0.0911
# checkresiduals(fit3.ets)
autoplot(ts.pa5, color = "white", lwd = 2) +
autolayer(fitpa5.ets$fitted, color = "blue")
forecast.ets(fitpa5.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 229306 178560 280052 151696 306915
## 2023.50 229306 175019 283592 146282 312329
## 2024.00 229306 171696 286915 141199 317412
## 2024.50 229306 168554 290057 136395 322217
## 2025.00 229306 165567 293044 131826 326785
## 2025.50 229306 162714 295897 127463 331148
## 2026.00 229306 159978 298633 123279 335333
## 2026.50 229306 157346 301265 119254 339358
## 2027.00 229306 154807 303804 115371 343241
## 2027.50 229306 152352 306259 111616 346996
fitpa5.holt<-holt(ts.pa5,alpha = 0.32,beta=0.01)
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
# summary(fit12.holt)
# checkresiduals(fit12.holt)
forecast(fitpa5.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 239616 187241 291990 159516 319715
## 2023.50 243140 187988 298292 158792 327488
## 2024.00 246664 188709 304620 158029 335300
## 2024.50 250189 189403 310974 157225 343152
## 2025.00 253713 190070 317356 156380 351046
## 2025.50 257237 190710 323765 155492 358982
## 2026.00 260762 191321 330202 154561 366962
## 2026.50 264286 191903 336668 153586 374985
## 2027.00 267810 192457 343164 152567 383053
## 2027.50 271335 192981 349688 151504 391166
autoplot(ts.pa5, color = "white", lwd = 2) +
autolayer(fitpa5.holt$fitted, color = "blue")
fitpa5.hw<-hw(ts.pa5,h=10,alpha=0.101,beta=0.10,gamma=0.1)
# autoplot(fit3.hw)
# summary(fit3.hw)
# checkresiduals(fit3.hw)
forecast(fitpa5.hw)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 251097 186575 315619 152419 349775
## 2023.50 263448 197636 329260 162797 364099
## 2024.00 269046 198331 339762 160896 377196
## 2024.50 281397 206097 356697 166236 396559
## 2025.00 286995 202297 371694 157460 416530
## 2025.50 299346 206193 392500 156881 441812
## 2026.00 304945 198415 411474 142022 467867
## 2026.50 317296 198891 435700 136212 498379
## 2027.00 322894 188020 457768 116622 529166
## 2027.50 335245 185704 484785 106542 563947
autoplot(ts.pa5, color = "white", lwd = 2) +
autolayer(fitpa5.hw$fitted, color = "blue")
####ARIMA
acf(ts.pa5)
pacf(ts.pa5)
fitpa5.TBATS<-tbats(ts.pa5)
autoplot(fitpa5.TBATS)
summary(fitpa5.TBATS)
## Length Class Mode
## lambda 0 -none- NULL
## alpha 1 -none- numeric
## beta 0 -none- NULL
## damping.parameter 0 -none- NULL
## gamma.values 0 -none- NULL
## ar.coefficients 0 -none- NULL
## ma.coefficients 0 -none- NULL
## likelihood 1 -none- numeric
## optim.return.code 1 -none- numeric
## variance 1 -none- numeric
## AIC 1 -none- numeric
## parameters 2 -none- list
## seed.states 1 -none- numeric
## fitted.values 20 ts numeric
## errors 20 ts numeric
## x 20 -none- numeric
## seasonal.periods 0 -none- NULL
## y 20 ts numeric
## call 2 -none- call
## series 1 -none- character
## method 1 -none- character
checkresiduals(fitpa5.TBATS)
##
## Ljung-Box test
##
## data: Residuals from TBATS
## Q* = 0.4, df = 4, p-value = 1
##
## Model df: 0. Total lags used: 4
autoplot(ts.pa5, color = "white", lwd = 2) +
autolayer(fitpa5.TBATS$fitted, color = "blue")
#### Model comparison
autoplot(ts.pa5, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fitpa5.ets$fitted, color = "red")+autolayer(fitpa5.holt$fitted, color = "yellow")+autolayer (fitpa5.hw$fitted, color = "grey")+autolayer (fitpa5.TBATS$fitted, color = "pink")
grid.arrange(autoplot(forecast(fitpa5.ets,h=5)), autoplot(forecast(fitpa5.arima,h=5)),autoplot(forecast(fitpa5.holt,h=5)),autoplot(forecast(fitpa5.hw,h=5)),autoplot(forecast(fitpa5.TBATS,h=5)))
fpa5.ets <- function (y,h) forecast(fitpa5.ets,h=h)
fpa5.arima <- function (y,h) forecast(fitpa5.arima,h=h)
fpa5.holt<- function (y,h) forecast(fitpa5.holt,h=h)
fpa5.hw<- function (y,h) forecast(fitpa5.hw,h=h)
fpa5.TBATS<- function (y,h) forecast(fitpa5.TBATS,h=h)
hmax<-5
epa5.ets<-na.omit(tsCV(ts.pa5,fpa5.ets,h=hmax))[,hmax]
epa5.arima<-na.omit(tsCV(ts.pa5,fpa5.arima,h=hmax))[,hmax]
epa5.holt<-na.omit(tsCV(ts.pa5,fpa5.holt,h=hmax))[,hmax]
epa5.hw<-na.omit(tsCV(ts.pa5,fpa5.hw,h=hmax))[,hmax]
epa5.TBATS<-na.omit(tsCV(ts.pa5,fpa5.TBATS,h=hmax))[,hmax]
summary(data.frame(epa5.ets^2,epa5.arima^2,epa5.holt^2,epa5.hw^2,epa5.TBATS^2))
## epa5.ets.2 epa5.arima.2 epa5.holt.2
## Min. : 1506423 Min. : 14042 Min. : 189088124
## 1st Qu.: 163426742 1st Qu.: 22656777 1st Qu.: 881717136
## Median : 471959792 Median : 636477212 Median :1939515588
## Mean :1374439670 Mean :1061762421 Mean :2873927146
## 3rd Qu.:2406159061 3rd Qu.:1153867898 3rd Qu.:3329663970
## Max. :5055300381 Max. :6959647200 Max. :9121765025
## epa5.hw.2 epa5.TBATS.2
## Min. : 3005562 Min. : 6303266
## 1st Qu.: 3073479313 1st Qu.: 118682421
## Median : 5978744948 Median : 236771134
## Mean : 6838719281 Mean :1072878887
## 3rd Qu.: 8256235735 3rd Qu.:1386340971
## Max. :16586952818 Max. :5114734113
vpa5<-fitpa5.ets$fitted
epa5<-abs(vpa5-ts.pa5)/ts.pa5
summary(epa5)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.005 0.063 0.116 0.146 0.219 0.417
mean(epa5)
## [1] 0.146
#####visualisation
ts.cp1<-ts(rev(b$cp1),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.cp1)
# plot(decompose(ts.pa3))
fitcp1.ets<-ets(ts.cp1)
# autoplot(fit3.ets)
summary(fitcp1.ets)
## ETS(A,N,N)
##
## Call:
## ets(y = ts.cp1)
##
## Smoothing parameters:
## alpha = 0.9999
##
## Initial states:
## l = 122217.3382
##
## sigma: 1698
##
## AIC AICc BIC
## 361 363 364
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 509 1611 509 0.392 0.392 0.45 0.439
# checkresiduals(fit3.ets)
autoplot(ts.cp1, color = "white", lwd = 2) +
autolayer(fitcp1.ets$fitted, color = "blue")
forecast.ets(fitcp1.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 132405 130229 134581 129077 135733
## 2023.50 132405 129328 135482 127699 137111
## 2024.00 132405 128637 136173 126642 138168
## 2024.50 132405 128054 136756 125750 139060
## 2025.00 132405 127540 137270 124965 139845
## 2025.50 132405 127076 137734 124255 140555
## 2026.00 132405 126649 138161 123602 141208
## 2026.50 132405 126252 138558 122994 141816
## 2027.00 132405 125878 138932 122423 142387
## 2027.50 132405 125525 139285 121883 142927
fitcp1.holt<-holt(ts.cp1)
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
# summary(fit12.holt)
# checkresiduals(fit12.holt)
forecast(fitcp1.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 133011 130696 135326 129470 136551
## 2023.50 133616 130225 137008 128429 138803
## 2024.00 134222 129923 138521 127647 140797
## 2024.50 134828 129694 139961 126976 142679
## 2025.00 135433 129503 141364 126363 144503
## 2025.50 136039 129332 142746 125781 146297
## 2026.00 136645 129171 144118 125214 148075
## 2026.50 137250 129014 145486 124654 149846
## 2027.00 137856 128858 146854 124095 151617
## 2027.50 138461 128699 148224 123531 153392
autoplot(ts.cp1, color = "white", lwd = 2) +
autolayer(fitcp1.holt$fitted, color = "blue")
fitcp1.hw<-hw(ts.cp1,h=10)
# autoplot(fit3.hw)
# summary(fit3.hw)
# checkresiduals(fit3.hw)
autoplot(ts.cp1, color = "white", lwd = 2) +
autolayer(fitcp1.hw$fitted, color = "blue")
####ARIMA
acf(ts.cp1)
pacf(ts.cp1)
fitcp1.arima<-auto.arima(ts.cp1)
# autoplot(fit3.arima)
# summary(fit3.arima)
# checkresiduals(fit3.arima)
autoplot(ts.cp1, color = "white", lwd = 2) +
autolayer(fitcp1.arima$fitted, color = "blue")
forecast(fitcp1.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 132405 130520 134290 129522 135288
## 2023.50 132405 129044 135766 127265 137545
## 2024.00 132405 127758 137052 125299 139511
## 2024.50 132405 126641 138169 123589 141221
## 2025.00 132405 125657 139153 122085 142725
## 2025.50 132405 124778 140032 120741 144069
## 2026.00 132405 123982 140828 119523 145287
## 2026.50 132405 123250 141560 118404 146406
## 2027.00 132405 122571 142239 117365 147445
## 2027.50 132405 121935 142875 116393 148417
fitcp1.TBATS<-tbats(ts.cp1)
autoplot(fitcp1.TBATS)
summary(fitcp1.TBATS)
## Length Class Mode
## lambda 1 -none- numeric
## alpha 1 -none- numeric
## beta 1 -none- numeric
## damping.parameter 1 -none- numeric
## gamma.values 0 -none- NULL
## ar.coefficients 0 -none- NULL
## ma.coefficients 0 -none- NULL
## likelihood 1 -none- numeric
## optim.return.code 1 -none- numeric
## variance 1 -none- numeric
## AIC 1 -none- numeric
## parameters 2 -none- list
## seed.states 2 -none- numeric
## fitted.values 20 ts numeric
## errors 20 ts numeric
## x 40 -none- numeric
## seasonal.periods 0 -none- NULL
## y 20 ts numeric
## call 2 -none- call
## series 1 -none- character
## method 1 -none- character
checkresiduals(fitcp1.TBATS)
##
## Ljung-Box test
##
## data: Residuals from TBATS
## Q* = 0.3, df = 4, p-value = 1
##
## Model df: 0. Total lags used: 4
autoplot(ts.cp1, color = "white", lwd = 2) +
autolayer(fitcp1.TBATS$fitted, color = "blue")
#### Model comparison
autoplot(ts.cp1, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fitcp1.ets$fitted, color = "red")+autolayer (fitcp1.arima$fitted, color = "blue")+autolayer(fitcp1.holt$fitted, color = "green")+autolayer (fitcp1.hw$fitted, color = "yellow")+autolayer (fitcp1.TBATS$fitted, color = "white")
grid.arrange(autoplot(forecast(fitcp1.ets,h=5)), autoplot(forecast(fitcp1.arima,h=5)),autoplot(forecast(fitcp1.holt,h=5)),autoplot(forecast(fitcp1.hw,h=5)),autoplot(forecast(fitcp1.TBATS,h=5)))
fcp1.ets <- function (y,h) forecast(fitcp1.ets,h=h)
fcp1.arima <- function (y,h) forecast(fitcp1.arima,h=h)
fcp1.holt<- function (y,h) forecast(fitcp1.holt,h=h)
fcp1.hw<- function (y,h) forecast(fitcp1.hw,h=h)
fcp1.TBATS<- function (y,h) forecast(fitcp1.TBATS,h=h)
hmax<-5
ecp1.ets<-na.omit(tsCV(ts.cp1,fcp1.ets,h=hmax))[,hmax]
ecp1.arima<-na.omit(tsCV(ts.cp1,fcp1.arima,h=hmax))[,hmax]
ecp1.holt<-na.omit(tsCV(ts.cp1,fcp1.holt,h=hmax))[,hmax]
ecp1.hw<-na.omit(tsCV(ts.cp1,fcp1.hw,h=hmax))[,hmax]
ecp1.TBATS<-na.omit(tsCV(ts.cp1,fcp1.TBATS,h=hmax))[,hmax]
summary(data.frame(ecp1.ets^2,ecp1.arima^2,ecp1.holt^2,ecp1.hw^2,ecp1.TBATS^2))
## ecp1.ets.2 ecp1.arima.2 ecp1.holt.2
## Min. : 0 Min. : 0 Min. : 9164226
## 1st Qu.: 0 1st Qu.: 0 1st Qu.: 9170282
## Median : 0 Median : 0 Median : 9170282
## Mean : 15559794 Mean : 15559794 Mean : 35010370
## 3rd Qu.: 0 3rd Qu.: 0 3rd Qu.: 9170282
## Max. :103734225 Max. :103734225 Max. :174589905
## ecp1.hw.2 ecp1.TBATS.2
## Min. : 2701009 Min. : 93305
## 1st Qu.: 2704297 1st Qu.: 93917
## Median : 2704297 Median : 93917
## Mean : 23846754 Mean : 16694079
## 3rd Qu.: 2704297 3rd Qu.: 93917
## Max. :139936472 Max. :110070715
vcp1<-fitcp1.ets$fitted
ecp1<-abs(vcp1-ts.cp1)/ts.cp1
summary(ecp1)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000 0.0000 0.0000 0.0039 0.0000 0.0400
mean(ecp1)
## [1] 0.00392
#####visualisation
ts.cp2<-ts(rev(b$cp2),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.cp2)
# plot(decompose(ts.pa3))
fitcp2.ets<-ets(ts.cp2)
# autoplot(fit3.ets)
summary(fitcp2.ets)
## ETS(A,A,A)
##
## Call:
## ets(y = ts.cp2)
##
## Smoothing parameters:
## alpha = 0.6374
## beta = 0.2295
## gamma = 0.0001
##
## Initial states:
## l = 347672.9196
## b = 33372.3802
## s = -19958 19958
##
## sigma: 25432
##
## AIC AICc BIC
## 473 482 480
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 2340 21278 15650 -0.0152 3.05 0.223 0.00514
# checkresiduals(fit3.ets)
autoplot(ts.cp2, color = "white", lwd = 2) +
autolayer(fitcp2.ets$fitted, color = "blue")
forecast.ets(fitcp2.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 1100012 1067419 1132604 1050166 1149857
## 2023.50 1104203 1061068 1147339 1038234 1170173
## 2024.00 1188236 1132219 1244254 1102565 1273907
## 2024.50 1192428 1121678 1263178 1084225 1300631
## 2025.00 1276461 1189421 1363501 1143345 1409577
## 2025.50 1280653 1175961 1385345 1120540 1440765
## 2026.00 1364686 1241107 1488264 1175689 1553683
## 2026.50 1368877 1225279 1512476 1149262 1588493
## 2027.00 1452910 1288229 1617592 1201051 1704770
## 2027.50 1457102 1270337 1643867 1171470 1742735
fitcp2.holt<-holt(ts.cp2)
# with or without dumping almost the same
# forecast(fit12.holt)
# autoplot(fit12.holt)
# summary(fit12.holt)
# checkresiduals(fit12.holt)
forecast(fitcp2.holt)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 1082474 1031892 1133055 1005116 1159832
## 2023.50 1119967 1063514 1176419 1033630 1206303
## 2024.00 1157459 1089630 1225289 1053723 1261195
## 2024.50 1194952 1110604 1279299 1065954 1323950
## 2025.00 1232445 1127363 1337526 1071737 1393153
## 2025.50 1269937 1140717 1399157 1072312 1467562
## 2026.00 1307430 1151238 1463622 1068555 1546305
## 2026.50 1344923 1159314 1530531 1061059 1628786
## 2027.00 1382415 1165215 1599615 1050237 1714594
## 2027.50 1419908 1169137 1670679 1036387 1803429
autoplot(ts.cp2, color = "white", lwd = 2) +
autolayer(fitcp2.holt$fitted, color = "blue")
fitcp2.hw<-hw(ts.cp2,h=10)
# autoplot(fit3.hw)
# summary(fit3.hw)
# checkresiduals(fit3.hw)
autoplot(ts.cp2, color = "white", lwd = 2) +
autolayer(fitcp2.hw$fitted, color = "blue")
####ARIMA
acf(ts.cp2)
pacf(ts.cp2)
fitcp2.arima<-auto.arima(ts.cp2)
# autoplot(fit3.arima)
# summary(fit3.arima)
# checkresiduals(fit3.arima)
autoplot(ts.cp2, color = "white", lwd = 2) +
autolayer(fitcp2.arima$fitted, color = "blue")
forecast(fitcp2.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 1105502 1074969 1136035 1058806 1152198
## 2023.50 1105175 1061995 1148355 1039137 1171213
## 2024.00 1196212 1121422 1271002 1081831 1310593
## 2024.50 1195885 1099332 1292438 1048220 1343550
## 2025.00 1286922 1153833 1420011 1083380 1490464
## 2025.50 1286595 1125031 1448159 1039504 1533686
## 2026.00 1377632 1175101 1580163 1067887 1687377
## 2026.50 1377305 1140799 1613811 1015601 1739009
## 2027.00 1468342 1186844 1749840 1037828 1898856
## 2027.50 1468015 1147785 1788245 978265 1957765
fitcp2.TBATS<-tbats(ts.cp2)
plot(fitcp2.TBATS)
summary(fitcp2.TBATS)
## Length Class Mode
## lambda 0 -none- NULL
## alpha 1 -none- numeric
## beta 1 -none- numeric
## damping.parameter 1 -none- numeric
## gamma.one.values 1 -none- numeric
## gamma.two.values 1 -none- numeric
## ar.coefficients 0 -none- NULL
## ma.coefficients 0 -none- NULL
## likelihood 1 -none- numeric
## optim.return.code 1 -none- numeric
## variance 1 -none- numeric
## AIC 1 -none- numeric
## parameters 2 -none- list
## seed.states 4 -none- numeric
## fitted.values 20 ts numeric
## errors 20 ts numeric
## x 80 -none- numeric
## seasonal.periods 1 -none- numeric
## k.vector 1 -none- numeric
## y 20 ts numeric
## p 1 -none- numeric
## q 1 -none- numeric
## call 2 -none- call
## series 1 -none- character
## method 1 -none- character
checkresiduals(fitcp2.TBATS)
##
## Ljung-Box test
##
## data: Residuals from TBATS
## Q* = 14, df = 4, p-value = 0.008
##
## Model df: 0. Total lags used: 4
autoplot(ts.cp2, color = "white", lwd = 2) +
autolayer(fitcp2.TBATS$fitted, color = "blue")
#### Model comparison
autoplot(ts.cp2, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fitcp2.ets$fitted, color = "red")+autolayer (fitcp2.arima$fitted, color = "blue")+autolayer(fitcp2.holt$fitted, color = "green")+autolayer (fitcp2.hw$fitted, color = "pink")+autolayer (fitcp2.TBATS$fitted, color = "yellow")
grid.arrange(autoplot(forecast(fitcp2.ets,h=5)), autoplot(forecast(fitcp2.arima,h=5)),autoplot(forecast(fitcp2.holt,h=5)),autoplot(forecast(fitcp2.hw,h=5)),autoplot(forecast(fitcp2.TBATS,h=5)))
fcp2.ets <- function (y,h) forecast(fitcp2.ets,h=h)
fcp2.arima <- function (y,h) forecast(fitcp2.arima,h=h)
fcp2.holt<- function (y,h) forecast(fitcp2.holt,h=h)
fcp2.hw<- function (y,h) forecast(fitcp2.hw,h=h)
fcp2.TBATS<- function (y,h) forecast(fitcp2.TBATS,h=h)
hmax<-5
ecp2.ets<-na.omit(tsCV(ts.cp2,fcp2.ets,h=hmax))[,hmax]
ecp2.arima<-na.omit(tsCV(ts.cp2,fcp2.arima,h=hmax))[,hmax]
ecp2.holt<-na.omit(tsCV(ts.cp2,fcp2.holt,h=hmax))[,hmax]
ecp2.hw<-na.omit(tsCV(ts.cp2,fcp2.hw,h=hmax))[,hmax]
ecp2.TBATS<-na.omit(tsCV(ts.cp2,fcp2.TBATS,h=hmax))[,hmax]
summary(data.frame(ecp2.ets^2,ecp2.arima^2,ecp2.holt^2,ecp2.hw^2,ecp2.TBATS^2))
## ecp2.ets.2 ecp2.arima.2 ecp2.holt.2
## Min. : 68470670666 Min. : 74054736900 Min. : 47372656963
## 1st Qu.:155454889849 1st Qu.:163771722409 1st Qu.:122858294966
## Median :291547092935 Median :302953369744 Median :245951133575
## Mean :325403290124 Mean :336855148954 Mean :279615536621
## 3rd Qu.:495985682856 3rd Qu.:510829681662 3rd Qu.:435924920894
## Max. :621566691406 Max. :638170908736 Max. :554099509291
## ecp2.hw.2 ecp2.TBATS.2
## Min. : 68472597489 Min. : 41326337552
## 1st Qu.:155457778476 1st Qu.:113059661886
## Median :291551068898 Median :231910438603
## Mean :325407282130 Mean :265512253772
## 3rd Qu.:495990868734 3rd Qu.:417163949942
## Max. :621572496796 Max. :532921613055
vcp2<-fitcp2.ets$fitted
ecp2<-abs(vcp2-ts.cp2)/ts.cp2
summary(ecp2)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0026 0.0091 0.0227 0.0305 0.0347 0.1937
mean(ecp2)
## [1] 0.0305
ts.cp4<-ts(rev(b$cp4),start=c(2013, 1),frequency=2)
fitcp4.ets<-ets(ts.cp4)
# autoplot(fit3.ets)
summary(fitcp4.ets)
## Simple exponential smoothing
##
## Call:
## ses(y = y, initial = "simple", alpha = 0.99999)
##
## Smoothing parameters:
## alpha = 1
##
## Initial states:
## l = 423
##
## sigma: 0
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 0 0 0 0 0 NaN NaN
# checkresiduals(fit3.ets)
autoplot(ts.cp4, color = "white", lwd = 2) +
autolayer(fitcp4.ets$fitted, color = "blue")
forecast.ets(fitcp4.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 423 423 423 423 423
## 2023.50 423 423 423 423 423
## 2024.00 423 423 423 423 423
## 2024.50 423 423 423 423 423
## 2025.00 423 423 423 423 423
## 2025.50 423 423 423 423 423
## 2026.00 423 423 423 423 423
## 2026.50 423 423 423 423 423
## 2027.00 423 423 423 423 423
## 2027.50 423 423 423 423 423
#####visualisation
ts.cp56<-ts(as.numeric(z[15,2:21]),start=c(2013, 1),frequency=2)
ggtsdisplay(ts.cp56)
# plot(decompose(ts.pa3))
fitcp56.ets<-ets(ts.cp56)
# autoplot(fit3.ets)
summary(fitcp56.ets)
## ETS(M,N,M)
##
## Call:
## ets(y = ts.cp56)
##
## Smoothing parameters:
## alpha = 0.7425
## gamma = 0.0001
##
## Initial states:
## l = 72516.4031
## s = 1.27 0.729
##
## sigma: 0.286
##
## AIC AICc BIC
## 466 470 471
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 3814 22169 15984 -3.19 22.8 0.561 -0.00223
# # checkresiduals(fit3.ets)
autoplot(ts.cp56, color = "white", lwd = 2) +
autolayer(fitcp56.ets$fitted, color = "blue")
forecast.ets(fitcp56.ets,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 86828 55052 118604 38231 135425
## 2023.50 151385 81390 221380 44337 258433
## 2024.00 86829 39490 134167 14430 159227
## 2024.50 151386 57523 245249 7835 294938
## 2025.00 86829 26951 146708 -4747 178406
## 2025.50 151387 37015 265759 -23530 326304
## 2026.00 86830 15741 157918 -21891 195550
## 2026.50 151388 18180 284596 -52337 355112
## 2027.00 86830 5242 168419 -37949 211609
## 2027.50 151389 271 302507 -79727 382504
fitcp56.hw<-hw(ts.cp56,h=10)
# autoplot(fit3.hw)
# summary(fit3.hw)
# checkresiduals(fit3.hw)
forecast(fitcp56.hw)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 91360 54763 127956 35389 147330
## 2023.50 143378 106758 179997 87373 199383
## 2024.00 96012 59369 132654 39972 152051
## 2024.50 148030 111364 184696 91955 204105
## 2025.00 100664 63974 137353 44552 156775
## 2025.50 152682 115969 189395 96534 208830
## 2026.00 105316 68578 142053 49131 161501
## 2026.50 157334 120572 194096 101112 213557
## 2027.00 109968 73181 146755 53707 166228
## 2027.50 161986 125174 198798 105687 218285
autoplot(ts.cp56, color = "white", lwd = 2) +
autolayer(fitcp56.hw$fitted, color = "blue")
acf(ts.cp56)
pacf(ts.cp56)
fitcp56.arima<-auto.arima(ts.cp56)
# autoplot(fit3.arima)
summary(fitcp56.arima)
## Series: ts.cp56
## ARIMA(0,0,0)(0,1,1)[2]
##
## Coefficients:
## sma1
## -0.600
## s.e. 0.192
##
## sigma^2 = 939098661: log likelihood = -211
## AIC=427 AICc=428 BIC=429
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 7745 28253 21164 0.532 25.5 0.742 0.286
# checkresiduals(fit3.arima)
autoplot(ts.cp56, color = "white", lwd = 2) +
autolayer(fitcp56.arima$fitted, color = "blue")
forecast(fitcp56.arima,h=10)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2023.00 72106 32832 111379 12042 132169
## 2023.50 136874 97601 176147 76811 196937
## 2024.00 72106 29802 114409 7408 136803
## 2024.50 136874 94571 179178 72177 201572
## 2025.00 72106 26975 117236 3084 141127
## 2025.50 136874 91744 182005 67853 205895
## 2026.00 72106 24315 119896 -984 145195
## 2026.50 136874 89083 184665 63785 209964
## 2027.00 72106 21795 122416 -4838 149049
## 2027.50 136874 86564 187185 59931 213817
#### Model comparison
autoplot(ts.cp56, color = "black", lwd = 2) +
# autolayer(bxcx(fit12.ets$fitted, lambda= BoxCox.lambda(ts.ac12) , InverseQ=TRUE), color = "blue", lwd = 1) +
# autolayer(bxcx(fit12.arima$fitted, lambda= BoxCox.lambda(ts.ac12), InverseQ=TRUE), color = "red", lwd = 1) +
autolayer(fitcp56.ets$fitted, color = "red")+autolayer (fitcp56.arima$fitted, color = "blue")+autolayer (fitcp56.hw$fitted, color = "yellow")+autolayer (fitcp56.TBATS$fitted, color = "pink")
grid.arrange(autoplot(forecast(fitcp56.ets,h=5)), autoplot(forecast(fitcp56.arima,h=5)),autoplot(forecast(fitcp56.holt,h=5)),autoplot(forecast(fitcp56.hw,h=5)),autoplot(forecast(fitcp56.TBATS,h=5)))
fcp56.ets <- function (y,h) forecast(fitcp56.ets,h=h)
fcp56.arima <- function (y,h) forecast(fitcp56.arima,h=h)
fcp56.holt<- function (y,h) forecast(fitcp56.holt,h=h)
fcp56.hw<- function (y,h) forecast(fitcp56.hw,h=h)
fcp56.TBATS<- function (y,h) forecast(fitcp56.TBATS,h=h)
hmax<-5
ecp56.ets<-na.omit(tsCV(ts.cp56,fcp56.ets,h=hmax))[,hmax]
ecp56.arima<-na.omit(tsCV(ts.cp56,fcp56.arima,h=hmax))[,hmax]
ecp56.holt<-na.omit(tsCV(ts.cp56,fcp56.holt,h=hmax))[,hmax]
ecp56.hw<-na.omit(tsCV(ts.cp56,fcp56.hw,h=hmax))[,hmax]
ecp56.TBATS<-na.omit(tsCV(ts.cp56,fcp56.TBATS,h=hmax))[,hmax]
summary(data.frame(ecp56.ets^2,ecp56.arima^2,ecp56.holt^2,ecp56.hw^2,ecp56.TBATS^2))
## ecp56.ets.2 ecp56.arima.2 ecp56.holt.2
## Min. : 7383179 Min. : 8234970 Min. : 2014004
## 1st Qu.: 327086242 1st Qu.: 232376589 1st Qu.: 613072382
## Median : 733694703 Median : 1099629619 Median :2205538033
## Mean :1713594307 Mean : 2118951960 Mean :3104608540
## 3rd Qu.:2063515707 3rd Qu.: 2020794263 3rd Qu.:4733266471
## Max. :9106274050 Max. :12133096580 Max. :9086885389
## ecp56.hw.2 ecp56.TBATS.2
## Min. : 999319 Min. : 4780384
## 1st Qu.: 224790981 1st Qu.: 615101431
## Median : 987697793 Median :2278191926
## Mean :1727798518 Mean :3163266107
## 3rd Qu.:2749055460 3rd Qu.:4839389461
## Max. :6657309999 Max. :9233751032
vcp56<-fitcp56.ets$fitted
ecp56<-abs(vcp56-ts.cp56)/ts.cp56
summary(ecp56)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.034 0.077 0.115 0.228 0.197 1.625
mean(ecp56)
## [1] 0.228
| juin_2013 | juin_2013_fitted | dec_2013 | dec_2013_fitted | juin_2014 | juin_2014_fitted | dec_2014 | dec_2014_fitted | juin_2015 | juin_2015_fitted | dec_2015 | dec_2015_fitted | juin_2016 | juin_2016_fitted | dec_2016 | dec_2016_fitted | juin_2017 | juin_2017_fitted | dec_2017 | dec_2017_fitted | juin_2018 | juin_2018_fitted | dec_2018 | dec_2018_fitted | juin_2019 | juin-2019_fitted | dec_2019 | dec-2019_fitted | juin_2020 | juin_2020_fitted | dec_2020 | dec_2020_fitted | juin_2021 | juin_2021_fitted | dec_2021 | dec_2021_fitted | juin_2022 | juin_2022_fitted | dec_2022 | dec_2022_fitted | juin_2023_forecast | dec_2023_forecast | juin_2024_forecast | dec_2024_forecast | juin_2025_forecast | dec_2025_forecast | juin_2026_forecast | dec_2026_forecast | juin_2027_forecast | dec_2027_forecast | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 707610 | 706902 | 547183 | 707610 | 566386 | 547183 | 397872 | 566386 | 319974 | 397872 | 301654 | 319974 | 236519 | 301654 | 277550 | 236519 | 284855 | 277550 | 367277 | 284855 | 345694 | 367277 | 585581 | 345694 | 776744 | 585581 | 1029846 | 776744 | 672299 | 1029846 | 657970 | 672299 | 967263 | 657970 | 529335 | 967263 | 809511 | 529335 | 587954 | 809511 | 597083 | 573376 | 547402 | 547402 | 497585 | 474925 | 466976 | 455412 | 432939 | 399910 |
| AC3: Créances sur la clientèle | 5426908 | 5649758 | 5484548 | 5260854 | 5785084 | 5542121 | 6116034 | 6085594 | 6100492 | 6447002 | 5971463 | 6085022 | 5951069 | 5842422 | 5893685 | 5930642 | 6002207 | 5836319 | 6073730 | 6110692 | 6127435 | 6145277 | 5929248 | 6181140 | 5764161 | 5731110 | 5727900 | 5599042 | 5849074 | 5691616 | 6003059 | 5970229 | 6121170 | 6157053 | 6245664 | 6239291 | 6541211 | 6370153 | 6889784 | 6836724 | 7238363 | 7586948 | 7935533 | 7935533 | 8632703 | 8981287 | 9329872 | 9678457 | 10027042 | 10375627 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 890448 | 889635 | 986109 | 968230 | 1174729 | 1063891 | 1279001 | 1252511 | 1369500 | 1356783 | 1476770 | 1447282 | 1599123 | 1554552 | 1792430 | 1676905 | 1927681 | 1870212 | 1892208 | 2005463 | 2035218 | 1969990 | 1897993 | 2113000 | 1816480 | 1975775 | 1794738 | 1894262 | 1913060 | 1872520 | 2114255 | 1990842 | 2148062 | 2192037 | 2270398 | 2225844 | 2243374 | 2348180 | 2368299 | 2321156 | 2425876 | 2500997 | 2583094 | 2583094 | 2739102 | 2820432 | 2903959 | 2987303 | 3064183 | 3139695 |
| AC6: Valeurs immobilisées | 109751 | 107229 | 111765 | 128023 | 114709 | 113042 | 113024 | 125305 | 117890 | 106661 | 117566 | 123622 | 122248 | 111274 | 120854 | 130808 | 121087 | 116873 | 163219 | 129503 | 164094 | 160628 | 166778 | 193379 | 176093 | 178420 | 188436 | 191996 | 193408 | 186511 | 208163 | 207023 | 245946 | 208573 | 270250 | 267179 | 296811 | 292132 | 397473 | 336961 | 429630 | 505295 | 564544 | 564544 | 699458 | 775124 | 834373 | 910038 | 969287 | 1044952 |
| AC7: Autres actifs | 63897 | 63833 | 96026 | 63897 | 92100 | 96026 | 88946 | 92100 | 82798 | 88946 | 72601 | 82798 | 155557 | 72601 | 158398 | 155557 | 150841 | 158398 | 159764 | 150841 | 161673 | 159764 | 233528 | 161673 | 206109 | 233528 | 210993 | 206109 | 177425 | 210993 | 194124 | 177425 | 177987 | 194124 | 227763 | 177987 | 210291 | 227763 | 163260 | 210291 | 163260 | 163260 | 163260 | 163260 | 163260 | 163260 | 163260 | 163260 | 163260 | 163260 |
| Total actifs | 7198614 | 7417358 | 7225631 | 7128614 | 7733008 | 7362263 | 7994877 | 8121895 | 7990654 | 8397264 | 7940054 | 8058698 | 8064516 | 7882503 | 8242917 | 8130431 | 8486671 | 8259352 | 8656198 | 8681353 | 8834114 | 8802936 | 8813128 | 8994886 | 8739587 | 8704413 | 8951913 | 8668152 | 8805266 | 8991487 | 9177571 | 9017818 | 9660428 | 9409757 | 9543410 | 9877564 | 10101198 | 9767562 | 10406770 | 10514643 | 10854212 | 11329876 | 11793834 | 11793834 | 12732108 | 13215028 | 13698440 | 14194470 | 14656711 | 15123443 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 846155 | 806035 | 656637 | 837557 | 649379 | 695411 | 669723 | 659245 | 1107235 | 667477 | 1009424 | 1012987 | 1038815 | 1010188 | 1287062 | 1032680 | 1452748 | 1232543 | 1559931 | 1405554 | 1479531 | 1526845 | 1307122 | 1489671 | 1336418 | 1346246 | 1299523 | 1338524 | 978034 | 1307882 | 1023860 | 1048726 | 1155600 | 1029189 | 854460 | 1128508 | 1194680 | 913193 | 1057694 | 1134352 | 1066675 | 1083678 | 1103170 | 1103170 | 1140964 | 1158529 | 1194537 | 1227301 | 1250863 | 1268148 |
| PA3: Dépôts et avoirs de la clientèle | 4771687 | 5150669 | 4964477 | 4771725 | 5392386 | 4964458 | 5534662 | 5392343 | 5089757 | 5534648 | 5142391 | 5089802 | 5224553 | 5142386 | 5116938 | 5224545 | 5132643 | 5116949 | 5137206 | 5132641 | 5372311 | 5137206 | 5516889 | 5372287 | 5492292 | 5516875 | 5559635 | 5492294 | 5703385 | 5559628 | 5861002 | 5703371 | 6132793 | 5860986 | 6343825 | 6132766 | 6619725 | 6343804 | 6990819 | 6619697 | 6990782 | 6990782 | 6990782 | 6990782 | 6990782 | 6990782 | 6990782 | 6990782 | 6990782 | 6990782 |
| PA4: Emprunts et Ressources spéciales | 866480 | 891345 | 846029 | 882437 | 908666 | 873918 | 895487 | 900011 | 928129 | 894521 | 911881 | 908119 | 885063 | 901350 | 914432 | 890178 | 982621 | 902413 | 968065 | 930819 | 922959 | 924755 | 876255 | 905965 | 815005 | 886509 | 875676 | 860994 | 830431 | 886268 | 968332 | 867420 | 957216 | 924866 | 926283 | 920236 | 840359 | 907350 | 825551 | 871556 | 865387 | 881982 | 888895 | 888895 | 892974 | 893474 | 893682 | 893769 | 893805 | 893820 |
| PA5: Autres passifs | 119823 | 168956 | 190029 | 156330 | 178860 | 170548 | 259758 | 176725 | 195751 | 207643 | 205186 | 208066 | 235983 | 211344 | 190154 | 223674 | 163567 | 217059 | 172039 | 203517 | 209673 | 196705 | 207581 | 204246 | 158205 | 208737 | 202531 | 195486 | 239962 | 200729 | 210426 | 216665 | 288729 | 217988 | 232599 | 244652 | 214701 | 244701 | 230533 | 238707 | 239616 | 243140 | 246664 | 246664 | 253713 | 257237 | 260762 | 264286 | 267810 | 271335 |
| Total passifs | 6604145 | 7017005 | 6657172 | 6648049 | 7129291 | 6704334 | 7359630 | 7128323 | 7320872 | 7304288 | 7268882 | 7218973 | 7384414 | 7265267 | 7508586 | 7371077 | 7731579 | 7468964 | 7837241 | 7672532 | 7984474 | 7785511 | 7907847 | 7972169 | 7801920 | 7958366 | 7937365 | 7887298 | 7751812 | 7954507 | 8063620 | 7836182 | 8534338 | 8033030 | 8357167 | 8426161 | 8869465 | 8409048 | 9104597 | 8864312 | 9162459 | 9199581 | 9229511 | 9229511 | 9278433 | 9300022 | 9339762 | 9376137 | 9403260 | 9424085 |
| CP1: Capital | 122220 | 122217 | 122220 | 122220 | 122220 | 122220 | 122220 | 122220 | 122220 | 122220 | 122220 | 122220 | 122220 | 122220 | 127313 | 122220 | 132406 | 127312 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 | 132405 |
| CP2: Réserves | 422421 | 401003 | 346012 | 413028 | 423377 | 433135 | 423431 | 407658 | 488010 | 481924 | 488066 | 471566 | 521710 | 551478 | 516585 | 515221 | 572184 | 578961 | 572213 | 556120 | 652693 | 631386 | 652478 | 635033 | 736510 | 720055 | 736529 | 728389 | 844595 | 813124 | 844373 | 840120 | 924022 | 930579 | 923755 | 932803 | 1014792 | 1011201 | 1014465 | 1018641 | 1100012 | 1104203 | 1188236 | 1188236 | 1276461 | 1280653 | 1364686 | 1368877 | 1452910 | 1457102 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 49407 | 52865 | 99806 | 87691 | 57700 | 55457 | 89176 | 99591 | 59128 | 52687 | 60462 | 100195 | 35750 | 40549 | 90011 | 64480 | 50079 | 47859 | 113916 | 86313 | 64140 | 61262 | 119996 | 110536 | 105394 | 67428 | 182256 | 166707 | 38945 | 102244 | 99664 | 96318 | 69236 | 56668 | 129656 | 115072 | 84112 | 72211 | 154879 | 141307 | 86828 | 151385 | 86829 | 86829 | 86829 | 151387 | 86830 | 151388 | 86830 | 151389 |
| Total capitaux propres | 594469 | 576509 | 568459 | 623361 | 603717 | 611235 | 635247 | 629892 | 669782 | 657254 | 671172 | 694403 | 680102 | 714670 | 734331 | 702344 | 755092 | 754556 | 818957 | 775262 | 849640 | 825477 | 905281 | 878396 | 937667 | 920311 | 1014548 | 1027924 | 1053454 | 1048196 | 1113951 | 1069266 | 1126090 | 1120075 | 1186243 | 1180703 | 1231733 | 1216240 | 1302173 | 1292776 | 1319668 | 1388417 | 1407893 | 1407893 | 1496118 | 1564868 | 1584343 | 1653093 | 1672569 | 1741319 |
| Total capitaux propres et passifs | 7198614 | 7593514 | 7225631 | 7271410 | 7733008 | 7315569 | 7994877 | 7758215 | 7990654 | 7961542 | 7940054 | 7913377 | 8064516 | 7979937 | 8242917 | 8073421 | 8486671 | 8223519 | 8656198 | 8447794 | 8834114 | 8610988 | 8813128 | 8850566 | 8739587 | 8878677 | 8951913 | 8915222 | 8805266 | 9002703 | 9177571 | 8905448 | 9660428 | 9153105 | 9543410 | 9606864 | 10101198 | 9625288 | 10406770 | 10157088 | 10482127 | 10587998 | 10637404 | 10637404 | 10774552 | 10864890 | 10924106 | 11029231 | 11075829 | 11165404 |
| fit13_1 | fit13_2 | |||
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 707610 | 706902 | 547183 | 707610 |
| AC3: Créances sur la clientèle | 5426908 | 5649758 | 5484548 | 5260854 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 890448 | 889635 | 986109 | 968230 |
| AC6: Valeurs immobilisées | 109751 | 107229 | 111765 | 128023 |
| AC7: Autres actifs | 63897 | 63833 | 96026 | 63897 |
| Total actifs | 7198614 | 7417358 | 7225631 | 7128614 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 846155 | 806035 | 656637 | 837557 |
| PA3: Dépôts et avoirs de la clientèle | 4771687 | 5150669 | 4964477 | 4771725 |
| PA4: Emprunts et Ressources spéciales | 866480 | 891345 | 846029 | 882437 |
| PA5: Autres passifs | 119823 | 168956 | 190029 | 156330 |
| Total passifs | 6604145 | 7017005 | 6657172 | 6648049 |
| CP1: Capital | 122220 | 122217 | 122220 | 122220 |
| CP2: Réserves | 422421 | 401003 | 346012 | 413028 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 49407 | 52865 | 99806 | 87691 |
| Total capitaux propres | 594469 | 576509 | 568459 | 623361 |
| Total capitaux propres et passifs | 7198614 | 7593514 | 7225631 | 7271410 |
| fit14_1 | fit14_2 | |||
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 566386 | 547183 | 397872 | 566386 |
| AC3: Créances sur la clientèle | 5785084 | 5542121 | 6116034 | 6085594 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 1174729 | 1063891 | 1279001 | 1252511 |
| AC6: Valeurs immobilisées | 114709 | 113042 | 113024 | 125305 |
| AC7: Autres actifs | 92100 | 96026 | 88946 | 92100 |
| Total actifs | 7733008 | 7362263 | 7994877 | 8121895 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 649379 | 695411 | 669723 | 659245 |
| PA3: Dépôts et avoirs de la clientèle | 5392386 | 4964458 | 5534662 | 5392343 |
| PA4: Emprunts et Ressources spéciales | 908666 | 873918 | 895487 | 900011 |
| PA5: Autres passifs | 178860 | 170548 | 259758 | 176725 |
| Total passifs | 7129291 | 6704334 | 7359630 | 7128323 |
| CP1: Capital | 122220 | 122220 | 122220 | 122220 |
| CP2: Réserves | 423377 | 433135 | 423431 | 407658 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 57700 | 55457 | 89176 | 99591 |
| Total capitaux propres | 603717 | 611235 | 635247 | 629892 |
| Total capitaux propres et passifs | 7733008 | 7315569 | 7994877 | 7758215 |
| fit15_1 | fit15_2 | |||
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 319974 | 397872 | 301654 | 319974 |
| AC3: Créances sur la clientèle | 6100492 | 6447002 | 5971463 | 6085022 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 1369500 | 1356783 | 1476770 | 1447282 |
| AC6: Valeurs immobilisées | 117890 | 106661 | 117566 | 123622 |
| AC7: Autres actifs | 82798 | 88946 | 72601 | 82798 |
| Total actifs | 7990654 | 8397264 | 7940054 | 8058698 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1107235 | 667477 | 1009424 | 1012987 |
| PA3: Dépôts et avoirs de la clientèle | 5089757 | 5534648 | 5142391 | 5089802 |
| PA4: Emprunts et Ressources spéciales | 928129 | 894521 | 911881 | 908119 |
| PA5: Autres passifs | 195751 | 207643 | 205186 | 208066 |
| Total passifs | 7320872 | 7304288 | 7268882 | 7218973 |
| CP1: Capital | 122220 | 122220 | 122220 | 122220 |
| CP2: Réserves | 488010 | 481924 | 488066 | 471566 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 59128 | 52687 | 60462 | 100195 |
| Total capitaux propres | 669782 | 657254 | 671172 | 694403 |
| Total capitaux propres et passifs | 7990654 | 7961542 | 7940054 | 7913377 |
| fit16_1 | fit16_2 | |||
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 236519 | 301654 | 277550 | 236519 |
| AC3: Créances sur la clientèle | 5951069 | 5842422 | 5893685 | 5930642 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 1599123 | 1554552 | 1792430 | 1676905 |
| AC6: Valeurs immobilisées | 122248 | 111274 | 120854 | 130808 |
| AC7: Autres actifs | 155557 | 72601 | 158398 | 155557 |
| Total actifs | 8064516 | 7882503 | 8242917 | 8130431 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1038815 | 1010188 | 1287062 | 1032680 |
| PA3: Dépôts et avoirs de la clientèle | 5224553 | 5142386 | 5116938 | 5224545 |
| PA4: Emprunts et Ressources spéciales | 885063 | 901350 | 914432 | 890178 |
| PA5: Autres passifs | 235983 | 211344 | 190154 | 223674 |
| Total passifs | 7384414 | 7265267 | 7508586 | 7371077 |
| CP1: Capital | 122220 | 122220 | 127313 | 122220 |
| CP2: Réserves | 521710 | 551478 | 516585 | 515221 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 35750 | 40549 | 90011 | 64480 |
| Total capitaux propres | 680102 | 714670 | 734331 | 702344 |
| Total capitaux propres et passifs | 8064516 | 7979937 | 8242917 | 8073421 |
| fit17_1 | fit17_2 | |||
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 284855 | 277550 | 367277 | 284855 |
| AC3: Créances sur la clientèle | 6002207 | 5836319 | 6073730 | 6110692 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 1927681 | 1870212 | 1892208 | 2005463 |
| AC6: Valeurs immobilisées | 121087 | 116873 | 163219 | 129503 |
| AC7: Autres actifs | 150841 | 158398 | 159764 | 150841 |
| Total actifs | 8486671 | 8259352 | 8656198 | 8681353 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1452748 | 1232543 | 1559931 | 1405554 |
| PA3: Dépôts et avoirs de la clientèle | 5132643 | 5116949 | 5137206 | 5132641 |
| PA4: Emprunts et Ressources spéciales | 982621 | 902413 | 968065 | 930819 |
| PA5: Autres passifs | 163567 | 217059 | 172039 | 203517 |
| Total passifs | 7731579 | 7468964 | 7837241 | 7672532 |
| CP1: Capital | 132406 | 127312 | 132405 | 132405 |
| CP2: Réserves | 572184 | 578961 | 572213 | 556120 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 50079 | 47859 | 113916 | 86313 |
| Total capitaux propres | 755092 | 754556 | 818957 | 775262 |
| Total capitaux propres et passifs | 8486671 | 8223519 | 8656198 | 8447794 |
| fit18_1 | fit18_2 | |||
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 345694 | 367277 | 585581 | 345694 |
| AC3: Créances sur la clientèle | 6127435 | 6145277 | 5929248 | 6181140 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 2035218 | 1969990 | 1897993 | 2113000 |
| AC6: Valeurs immobilisées | 164094 | 160628 | 166778 | 193379 |
| AC7: Autres actifs | 161673 | 159764 | 233528 | 161673 |
| Total actifs | 8834114 | 8802936 | 8813128 | 8994886 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1479531 | 1526845 | 1307122 | 1489671 |
| PA3: Dépôts et avoirs de la clientèle | 5372311 | 5137206 | 5516889 | 5372287 |
| PA4: Emprunts et Ressources spéciales | 922959 | 924755 | 876255 | 905965 |
| PA5: Autres passifs | 209673 | 196705 | 207581 | 204246 |
| Total passifs | 7984474 | 7785511 | 7907847 | 7972169 |
| CP1: Capital | 132405 | 132405 | 132405 | 132405 |
| CP2: Réserves | 652693 | 631386 | 652478 | 635033 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 64140 | 61262 | 119996 | 110536 |
| Total capitaux propres | 849640 | 825477 | 905281 | 878396 |
| Total capitaux propres et passifs | 8834114 | 8610988 | 8813128 | 8850566 |
| fit19_1 | fit19_2 | |||
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 776744 | 585581 | 1029846 | 776744 |
| AC3: Créances sur la clientèle | 5764161 | 5731110 | 5727900 | 5599042 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 1816480 | 1975775 | 1794738 | 1894262 |
| AC6: Valeurs immobilisées | 176093 | 178420 | 188436 | 191996 |
| AC7: Autres actifs | 206109 | 233528 | 210993 | 206109 |
| Total actifs | 8739587 | 8704413 | 8951913 | 8668152 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1336418 | 1346246 | 1299523 | 1338524 |
| PA3: Dépôts et avoirs de la clientèle | 5492292 | 5516875 | 5559635 | 5492294 |
| PA4: Emprunts et Ressources spéciales | 815005 | 886509 | 875676 | 860994 |
| PA5: Autres passifs | 158205 | 208737 | 202531 | 195486 |
| Total passifs | 7801920 | 7958366 | 7937365 | 7887298 |
| CP1: Capital | 132405 | 132405 | 132405 | 132405 |
| CP2: Réserves | 736510 | 720055 | 736529 | 728389 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 105394 | 67428 | 182256 | 166707 |
| Total capitaux propres | 937667 | 920311 | 1014548 | 1027924 |
| Total capitaux propres et passifs | 8739587 | 8878677 | 8951913 | 8915222 |
| fit20_1 | fit20_2 | |||
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 672299 | 1029846 | 657970 | 672299 |
| AC3: Créances sur la clientèle | 5849074 | 5691616 | 6003059 | 5970229 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 1913060 | 1872520 | 2114255 | 1990842 |
| AC6: Valeurs immobilisées | 193408 | 186511 | 208163 | 207023 |
| AC7: Autres actifs | 177425 | 210993 | 194124 | 177425 |
| Total actifs | 8805266 | 8991487 | 9177571 | 9017818 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 978034 | 1307882 | 1023860 | 1048726 |
| PA3: Dépôts et avoirs de la clientèle | 5703385 | 5559628 | 5861002 | 5703371 |
| PA4: Emprunts et Ressources spéciales | 830431 | 886268 | 968332 | 867420 |
| PA5: Autres passifs | 239962 | 200729 | 210426 | 216665 |
| Total passifs | 7751812 | 7954507 | 8063620 | 7836182 |
| CP1: Capital | 132405 | 132405 | 132405 | 132405 |
| CP2: Réserves | 844595 | 813124 | 844373 | 840120 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 38945 | 102244 | 99664 | 96318 |
| Total capitaux propres | 1053454 | 1048196 | 1113951 | 1069266 |
| Total capitaux propres et passifs | 8805266 | 9002703 | 9177571 | 8905448 |
| fit21_1 | fit21_2 | |||
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 967263 | 657970 | 529335 | 967263 |
| AC3: Créances sur la clientèle | 6121170 | 6157053 | 6245664 | 6239291 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 2148062 | 2192037 | 2270398 | 2225844 |
| AC6: Valeurs immobilisées | 245946 | 208573 | 270250 | 267179 |
| AC7: Autres actifs | 177987 | 194124 | 227763 | 177987 |
| Total actifs | 9660428 | 9409757 | 9543410 | 9877564 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1155600 | 1029189 | 854460 | 1128508 |
| PA3: Dépôts et avoirs de la clientèle | 6132793 | 5860986 | 6343825 | 6132766 |
| PA4: Emprunts et Ressources spéciales | 957216 | 924866 | 926283 | 920236 |
| PA5: Autres passifs | 288729 | 217988 | 232599 | 244652 |
| Total passifs | 8534338 | 8033030 | 8357167 | 8426161 |
| CP1: Capital | 132405 | 132405 | 132405 | 132405 |
| CP2: Réserves | 924022 | 930579 | 923755 | 932803 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 69236 | 56668 | 129656 | 115072 |
| Total capitaux propres | 1126090 | 1120075 | 1186243 | 1180703 |
| Total capitaux propres et passifs | 9660428 | 9153105 | 9543410 | 9606864 |
| fit22_1 | fit22_2 | |||
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 809511 | 529335 | 587954 | 809511 |
| AC3: Créances sur la clientèle | 6541211 | 6370153 | 6889784 | 6836724 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 2243374 | 2348180 | 2368299 | 2321156 |
| AC6: Valeurs immobilisées | 296811 | 292132 | 397473 | 336961 |
| AC7: Autres actifs | 210291 | 227763 | 163260 | 210291 |
| Total actifs | 10101198 | 9767562 | 10406770 | 10514643 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1194680 | 913193 | 1057694 | 1134352 |
| PA3: Dépôts et avoirs de la clientèle | 6619725 | 6343804 | 6990819 | 6619697 |
| PA4: Emprunts et Ressources spéciales | 840359 | 907350 | 825551 | 871556 |
| PA5: Autres passifs | 214701 | 244701 | 230533 | 238707 |
| Total passifs | 8869465 | 8409048 | 9104597 | 8864312 |
| CP1: Capital | 132405 | 132405 | 132405 | 132405 |
| CP2: Réserves | 1014792 | 1011201 | 1014465 | 1018641 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 84112 | 72211 | 154879 | 141307 |
| Total capitaux propres | 1231733 | 1216240 | 1302173 | 1292776 |
| Total capitaux propres et passifs | 10101198 | 9625288 | 10406770 | 10157088 |
| fit23_1 | fit23_2 | fit24_1 | fit24_1 | |
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 597083 | 573376 | 547402 | 547402 |
| AC3: Créances sur la clientèle | 7238363 | 7586948 | 7935533 | 7935533 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 2425876 | 2500997 | 2583094 | 2583094 |
| AC6: Valeurs immobilisées | 429630 | 505295 | 564544 | 564544 |
| AC7: Autres actifs | 163260 | 163260 | 163260 | 163260 |
| Total actifs | 10854212 | 11329876 | 11793834 | 11793834 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1066675 | 1083678 | 1103170 | 1103170 |
| PA3: Dépôts et avoirs de la clientèle | 6990782 | 6990782 | 6990782 | 6990782 |
| PA4: Emprunts et Ressources spéciales | 865387 | 881982 | 888895 | 888895 |
| PA5: Autres passifs | 239616 | 243140 | 246664 | 246664 |
| Total passifs | 9162459 | 9199581 | 9229511 | 9229511 |
| CP1: Capital | 132405 | 132405 | 132405 | 132405 |
| CP2: Réserves | 1100012 | 1104203 | 1188236 | 1188236 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 86828 | 151385 | 86829 | 86829 |
| Total capitaux propres | 1319668 | 1388417 | 1407893 | 1407893 |
| Total capitaux propres et passifs | 10482127 | 10587998 | 10637404 | 10637404 |
| fit25_1 | fit25_2 | fit26_1 | fit26_2 | |
|---|---|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 497585 | 474925 | 466976 | 455412 |
| AC3: Créances sur la clientèle | 8632703 | 8981287 | 9329872 | 9678457 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 2739102 | 2820432 | 2903959 | 2987303 |
| AC6: Valeurs immobilisées | 699458 | 775124 | 834373 | 910038 |
| AC7: Autres actifs | 163260 | 163260 | 163260 | 163260 |
| Total actifs | 12732108 | 13215028 | 13698440 | 14194470 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1140964 | 1158529 | 1194537 | 1227301 |
| PA3: Dépôts et avoirs de la clientèle | 6990782 | 6990782 | 6990782 | 6990782 |
| PA4: Emprunts et Ressources spéciales | 892974 | 893474 | 893682 | 893769 |
| PA5: Autres passifs | 253713 | 257237 | 260762 | 264286 |
| Total passifs | 9278433 | 9300022 | 9339762 | 9376137 |
| CP1: Capital | 132405 | 132405 | 132405 | 132405 |
| CP2: Réserves | 1276461 | 1280653 | 1364686 | 1368877 |
| CP4: Autres capitaux propres | 423 | 423 | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 86829 | 151387 | 86830 | 151388 |
| Total capitaux propres | 1496118 | 1564868 | 1584343 | 1653093 |
| Total capitaux propres et passifs | 10774552 | 10864890 | 10924106 | 11029231 |
| fit27_1 | fit27_2 | |
|---|---|---|
| AC12: Caisse et avoirs auprès de la BCT, CCP et TGT + Créances sur les établissements bancaires et financiers | 432939 | 399910 |
| AC3: Créances sur la clientèle | 10027042 | 10375627 |
| AC45: Portefeuille-titres commercial et Portefeuille d’investissement | 3064183 | 3139695 |
| AC6: Valeurs immobilisées | 969287 | 1044952 |
| AC7: Autres actifs | 163260 | 163260 |
| Total actifs | 14656711 | 15123443 |
| PA12: Banque Centrale et CCP et Dépôts et avoirs des établissements bancaires et financiers | 1250863 | 1268148 |
| PA3: Dépôts et avoirs de la clientèle | 6990782 | 6990782 |
| PA4: Emprunts et Ressources spéciales | 893805 | 893820 |
| PA5: Autres passifs | 267810 | 271335 |
| Total passifs | 9403260 | 9424085 |
| CP1: Capital | 132405 | 132405 |
| CP2: Réserves | 1452910 | 1457102 |
| CP4: Autres capitaux propres | 423 | 423 |
| CP56: Résultat de l’exercice et résultats reportés | 86830 | 151389 |
| Total capitaux propres | 1672569 | 1741319 |
| Total capitaux propres et passifs | 11075829 | 11165404 |
error<-c()
for (i in seq(from = 1, to = 39, by = 2)){
actual<-c(bss[,i])
predicted<-c(bss[,i+1])
relative_error <- abs(actual - predicted) / actual
error<-c(error,mean(relative_error))
}
print(error)
## [1] 0.0548 0.1059 0.0411 0.0705 0.0740 0.0632 0.0825 0.0684 0.0540 0.0733
## [11] 0.0253 0.0833 0.0792 0.0359 0.1844 0.0304 0.0796 0.0981 0.0767 0.0718
mean(error)
## [1] 0.0726